Synchronization method and apparatus

ABSTRACT

A synchronization method and an apparatus are provided to meet a time precision requirement of an industrial factory in a scenario in which a mobile network is connected to an Ethernet network. In an embodiment, a first device determines seventh timestamp information by using timestamp information of receiving and sending packets in a mobile network, so that a second device calculates a time offset between the first device and the second device based on the seventh timestamp information and time points of receiving and sending packets in an Ethernet network, to perform time synchronization. In the method, impact of a transmission delay between the first device and the second device can be avoided, so that a time precision requirement of an industrial factory can be met in a scenario in which the mobile network is connected to the Ethernet network.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of International Patent ApplicationNo. PCT/CN2019/093123, filed on Jun. 26, 2019, which claims priority toChinese Patent Application No. 201811168721.8 filed on Oct. 8, 2018 andChinese Patent Application No. 201810672083.7 filed on Jun. 26, 2018.All of the aforementioned patent applications are hereby incorporated byreference in their entireties.

TECHNICAL FIELD

This application relates to the field of communications technologies,and in particular, to a synchronization method and an apparatus.

BACKGROUND

A master clock selection and negotiation algorithm, a path delaycalculation and compensation mechanism, and a clock frequency matchingand adjustment mechanism are defined in the IEEE 802.1AS protocol.Communications devices exchange standard Ethernet messages, tosynchronize times of all nodes in a network with a common master clock.This defines a precise clock synchronization system in a broad sense.For example, the 802.1AS protocol defines that network-widesynchronization is implemented in a hop-by-hop synchronization manner.For example, a master clock node (referred to as a master below) startsto send an 802.1AS synchronization packet to a neighboring node(referred to as a slaver below). After each slaver performs clocksynchronization with reference to the master, the slaver serves as amaster to exchange the 802.1AS synchronization packet with a neighboringnode, and obtains a time offset and/or a frequency offset between amaster clock and a slave clock through calculation to implement clocksynchronization.

For example, an 802.1AS time synchronization mechanism is as follows:The master and the slaver send 802.1AS packets to each other, andcalculate a time offset based on time points of receiving and sendingpackets by the master and time points of receiving and sending packetsby the slaver. However, when the master sends a packet to the slaver andthe slaver sends a packet to the master, there is an unknowntransmission delay. Therefore, a transmission delay needs to beconsidered during calculation of the time offset. 802.1AS timesynchronization is implemented based on the same delay for receiving andsending packets. For example, precise time synchronization can beimplemented only when transmission delays are the same. In an existingfixed network, two adjacent nodes are directly connected through acable, and a transmission delay does not exceed μs. Therefore, precisionof the 802.1AS protocol in the fixed network can reach μs. This meets arequirement.

An 802.1AS frequency synchronization mechanism is as follows: The mastersends 802.1AS packets to the slaver at two different time points. Theslaver calculates a frequency offset based on the two sending timepoints of the master and two receiving time points. Similarly, an802.1AS frequency synchronization principle is as follows: precisefrequency synchronization can be implemented only when delays in twotimes of packet transmission are the same. Therefore, a requirement canbe met in the fixed network.

Currently, the IEEE 802.1AS protocol is widely used. For example, a timesensitive network (TSN) is an Ethernet network in an industrial factory.To meet a high-precision clock synchronization requirement in theindustrial factory, the 802.1AS protocol is used as a protocolspecification for clock synchronization in the TSN. However, in anactual industrial factory scenario, a mobile network needs to beconnected to the TSN, and the mobile network is used as a segment of atransmission path to provide a communications service for the industrialfactory. Therefore, the mobile network also needs to support the 802.1ASprotocol. However, when two adjacent nodes (for example, a terminaldevice and a user plane network element) in the TSN perform clocksynchronization, a packet passes through a multi-hop device (forexample, an access device) in the mobile network in a transmissionprocess. Therefore, co-directional transmission delays and round-triptransmission delays of packets transmitted between the two adjacentnodes may be different. Therefore, the 802.1AS synchronization mechanismcannot be met, and consequently a time precision requirement of theindustrial factory cannot be met.

SUMMARY

This application provides a synchronization method and apparatus, tomeet a time precision requirement of an industrial factory in a scenarioin which a mobile network is connected to an Ethernet network (forexample, a TSN).

According to a first aspect, this application provides a synchronizationmethod.

First, a first device sends a first packet to an access device, wherethe first packet carries first timestamp information, and determinessecond timestamp information, where the first timestamp information is amoment that is in an Ethernet network and at which the first devicesends the first packet, and the second timestamp information is a momentthat is in a mobile network and at which the first device sends thefirst packet. Then, the first device receives a second packet from anaccess device, where the second packet carries third timestampinformation and fourth timestamp information, the third timestampinformation is a moment that is in the mobile network and at which asecond device receives a third packet sent by the access device to thesecond device based on the first packet, the fourth timestampinformation is a moment that is in the mobile network and at which thesecond device sends a fourth packet to the access device, and the secondpacket is sent by the access device to the first device based on thefourth packet. Subsequently, the first device determines fifth timestampinformation and sixth timestamp information, where the fifth timestampinformation is a moment that is in the Ethernet network and at which thefirst device receives the second packet, and the sixth timestampinformation is a moment that is in the mobile network and at which thefirst device receives the second packet. Finally, the first devicedetermines seventh timestamp information based on the second timestampinformation, the third timestamp information, the fourth timestampinformation, the fifth timestamp information, and the sixth timestampinformation, and the first device forwards the seventh timestampinformation to the second device by using the access device. The firstdevice is a user plane network element and the second device is aterminal device, or the first device is a terminal device and the seconddevice is a user plane network element.

According an embodiment, the first device determines the seventhtimestamp information by using timestamp information of receiving andsending packets in the mobile network, so that the second devicecalculates a time offset between the first device and the second devicebased on the seventh timestamp information and time points of receivingand sending packets in the Ethernet network, to perform timesynchronization. In the method, impact of a transmission delay betweenthe first device and the second device can be avoided, so that a timeprecision requirement of an industrial factory can be met in a scenarioin which the mobile network is connected to the Ethernet network.

In an embodiment, a method in which the first device determines theseventh timestamp information based on the second timestamp information,the third timestamp information, the fourth timestamp information, thefifth timestamp information, and the sixth timestamp information may be:After determining a round-trip transmission delay difference between thefirst device and the second device based on the second timestampinformation, the third timestamp information, the fourth timestampinformation, and the sixth timestamp information, the first devicecalculates a sum of the moment corresponding to the fifth timestampinformation and the round-trip transmission delay difference, to obtainthe seventh timestamp information.

According to an embodiment, the first device may accurately obtain theseventh timestamp information, so that the second device calculates atime offset between the first device and the second device based on theseventh timestamp information and time points of receiving and sendingpackets in the Ethernet network, to perform time synchronization.

In an embodiment, after determining the second timestamp information,the first device locally records the second timestamp information, sothat the first device subsequently calculates the round-triptransmission delay difference between the first device and the seconddevice. In this way, the first device may subsequently obtain theseventh timestamp information by using the recorded second timestampinformation.

In an embodiment, after receiving the second packet from the accessdevice, the first device extracts the third timestamp information andthe fourth timestamp information that are carried in a first protocolfield included in the second packet.

According to the method, the first device may subsequently determine theseventh timestamp information by using the third timestamp informationand the fourth timestamp information.

In an embodiment, the first protocol field may be an existing protocolfield, or may be a newly added protocol field in an existing protocolstack framework. For example, if the first protocol field is theexisting protocol field, when the first device is the user plane networkelement, the first protocol field may be a general packet radio service(GPRS) tunneling protocol (GTP) field. When the first device is theterminal device, the first protocol field may be a service data protocol(SDAP) field or a packet data convergence protocol (PDCP) field. Foranother example, when the first protocol field is the newly addedprotocol field, the first protocol field may be a NEW field.

According to the method, the access device may use the protocol field inthe packet to carry the third timestamp information and the fourthtimestamp information, to send the third timestamp information and thefourth timestamp information to the first device.

In an embodiment, there may be the following three cases in which afterreceiving the second packet from the access device, the first deviceextracts the third timestamp information and the fourth timestampinformation that are carried in the first protocol field included in thesecond packet.

Case 1: The first device extracts the third timestamp information andthe fourth timestamp information from the GTP field. In this case, thefirst device is the user plane network element.

Case 2: The first device extracts the third timestamp information andthe fourth timestamp information from the SDAP field or the PDCP field.In this case, the first device is the terminal device.

Case 3: The first device extracts the third timestamp information andthe fourth timestamp information from the NEW field. In this case, thefirst device is the terminal device or the user plane network element.

According to the method, the first device can accurately obtain thethird timestamp information and the fourth timestamp information.

According to a second aspect, this application further provides asynchronization method.

After receiving a first packet from a first device, an access devicesends a third packet to a second device based on the first packet, wherethe first packet carries first timestamp information, the firsttimestamp information is a moment that is in an Ethernet network and atwhich the first device sends the first packet, and the third packetcarries the first timestamp information. After receiving a fourth packetfrom the second device, the access device sends a second packet to thefirst device, where the fourth packet carries third timestampinformation and fourth timestamp information, the third timestampinformation is a moment that is in a mobile network and at which thesecond device receives the third packet, the fourth timestampinformation is a moment that is in the mobile network and at which thesecond device sends the fourth packet to the access device, and thesecond packet carries the third timestamp information and the fourthtimestamp information. The access device receives seventh timestampinformation from the first device, and sends the seventh timestampinformation to the second device. The first device is a user planenetwork element and the second device is a terminal device, or the firstdevice is a terminal device and the second device is a user planenetwork element.

According to an embodiment, the access device transmits timestampinformation required for clock synchronization to the first device andthe second device, to complete clock synchronization.

In an embodiment, a method in which the access device sends the secondpacket to the first device may be: When detecting that a second protocolfield included in the fourth packet carries the third timestampinformation and the fourth timestamp information, the access deviceencapsulates the third timestamp information and the fourth timestampinformation in a first protocol field included in the fourth packet togenerate the second packet, and sends the second packet to the firstdevice.

According to the method, the access device may successfully send thethird timestamp information and the fourth timestamp information to thefirst device, so that the first device determines the seventh timestampinformation.

In an embodiment, before encapsulating the third timestamp informationand the fourth timestamp information in the first protocol fieldincluded in the fourth packet, the access device extracts the thirdtimestamp information and the fourth timestamp information that arecarried in the second protocol field included in the fourth packet.

In an embodiment, the first protocol field may be an existing protocolfield, or may be a newly added protocol field (for example, a NEW field)in an existing protocol stack framework. The second protocol field mayalternatively be an existing protocol field, or may be a newly addedprotocol field (for example, a NEW field) in an existing protocol stackframework.

In an embodiment, when the first device is the user plane networkelement, the second protocol field is a SDAP field or a PDCP field, andthe first protocol field is a GTP field. When the first device is theterminal device, the second protocol field is a GTP field, and the firstprotocol field is an SDAP field or a PDCP field.

According to a third aspect, this application further provides asynchronization method.

A second device receives a third packet from an access device, where thethird packet carries first timestamp information, the first timestampinformation is a moment that is in an Ethernet network and at which afirst device sends a first packet, and the third packet is sent by theaccess device based on the first packet after the access device receivesthe first packet from the first device. The first device is a user planenetwork element and the second device is a terminal device, or the firstdevice is a terminal device and the second device is a user planenetwork element. Then, the second device determines third timestampinformation and eighth timestamp information, where the third timestampinformation is a moment that is in a mobile network and at which thesecond device receives the third packet, and the eighth timestampinformation is a moment that is in the Ethernet network and at which thesecond device receives the third packet. The second device sends afourth packet to the access device, where the fourth packet carries thethird timestamp information and fourth timestamp information, and thefourth timestamp information is a moment that is in the mobile networkand at which the second device sends the fourth packet to the accessdevice. Then, the second device determines ninth timestamp information,where the ninth timestamp information is a moment that is in theEthernet network and at which the second device sends the fourth packetto the access device. Finally, the second device receives seventhtimestamp information from the access device; and determines a timeoffset between the first device and the second device based on the firsttimestamp information, the eighth timestamp information, the ninthtimestamp information, and the seventh timestamp information, andperforms time synchronization based on the time offset.

According to an embodiment, the second device calculates the time offsetbetween the first device and the second device based on the seventhtimestamp information and time points of receiving and sending packetsin the Ethernet network, to perform time synchronization. In the method,impact of a transmission delay between the first device and the seconddevice can be avoided, so that a time precision requirement of anindustrial factory can be met in a scenario in which the mobile networkis connected to the Ethernet network.

In an embodiment, the second device determines, based on the seventhtimestamp information, a moment that is in the Ethernet network and atwhich the first device receives the second packet, where the secondpacket is sent by the access device to the first device based on thefourth packet. In this way, the second device may perform timesynchronization based on the seventh timestamp information.

In an embodiment, that the fourth packet carries the third timestampinformation and fourth timestamp information is: The second device usesa second protocol field included in the fourth packet to carry the thirdtimestamp information and the fourth timestamp information. In this way,the second device can successfully transmit the third timestampinformation and the fourth timestamp information to the access device.

In an embodiment, the second protocol field may be an existing protocolfield, or may be a newly added protocol field (for example, a NEW field)in an existing protocol stack framework.

In an embodiment, when the second device is the terminal device, thesecond protocol field is a SDAP field or a PDCP field. When the seconddevice is the user plane network element, the second protocol field is aGTP field.

According to a fourth aspect, this application further provides asynchronization method.

A first device sends a first packet to an access device, where the firstpacket carries first timestamp information and second timestampinformation, the first timestamp information is a moment that is in anEthernet network and at which the first device sends the first packet,and the second timestamp information is a moment that is in a mobilenetwork and at which the first device sends the first packet. Then, thefirst device receives a second packet from the access device, anddetermines third timestamp information and fourth timestamp information,where the third timestamp information is a moment that is in theEthernet network and at which the first device receives the secondpacket, and the fourth timestamp information is a moment that is in themobile network and at which the first device receives the second packet.Finally, the first device sends the third timestamp information and thefourth timestamp information to the access device, where the firsttimestamp information, the second timestamp information, the thirdtimestamp information, and the fourth timestamp information are used fortime synchronization. The first device is a user plane network elementand a second device is a terminal device, or the first device is aterminal device and a second device is a user plane network element.

According to an embodiment, the first device sends, to the seconddevice, timestamp information of receiving and sending packets in themobile network, so that the second device calculates a time offsetbetween the first device and the second device by using the timestampinformation of receiving and sending the packets in the mobile networkand timestamp information of receiving and sending packets in theEthernet network, to perform time synchronization. Impact of atransmission delay between the first device and the second device can beavoided, so that a time precision requirement of an industrial factorycan be met in a scenario in which the mobile network is connected to theEthernet network.

In an embodiment, that the first packet carries second timestampinformation may be: The first device uses a first protocol fieldincluded in the first packet to carry the second timestamp information.

According to an embodiment, the first device can successfully transmitthe second timestamp information to the access device, so that theaccess device subsequently transmits the second timestamp information tothe second device.

In an embodiment, the first protocol field may be an existing protocolfield, or may be a newly added protocol field (for example, a NEW field)in an existing protocol stack framework.

In an embodiment, when the first device is the user plane networkelement, the first protocol field is a GTP field. When the first deviceis the terminal device, the first protocol field is a field or a PDCPfield.

According to a fifth aspect, this application further provides asynchronization method.

After receiving a first packet from a first device, an access devicesends a third packet to a second device based on the first packet, wherethe first packet carries first timestamp information and secondtimestamp information, the first timestamp information is a moment thatis in an Ethernet network and at which the first device sends the firstpacket, the second timestamp information is a moment that is in a mobilenetwork and at which the first device sends the first packet, and thethird packet carries the first timestamp information and the secondtimestamp information. The access device receives a fourth packet fromthe second device, and sends a second packet to the first device basedon the fourth packet. The access device receives third timestampinformation and fourth timestamp information from the first device,where the third timestamp information is a moment that is in theEthernet network and at which the first device receives the secondpacket, and the fourth timestamp information is a moment that is in themobile network and at which the first device receives the second packet.The access device sends the third timestamp information and the fourthtimestamp information to the second device, where the first timestampinformation, the second timestamp information, the third timestampinformation, and the fourth timestamp information are used for timesynchronization. The first device is a user plane network element andthe second device is a terminal device, or the first device is aterminal device and the second device is a user plane network element.

According to an embodiment, the access device transmits timestampinformation required for clock synchronization to the first device andthe second device, to complete clock synchronization.

In an embodiment, a method in which the access device sends the thirdpacket to the second device based on the first packet may be: When theaccess device detects that a first protocol field included in the firstpacket includes the second timestamp information, the access deviceencapsulates the second timestamp information in a second protocol fieldincluded in the first packet to generate the third packet, and sends thethird packet to the second device.

According to an embodiment, the access device may successfully send thesecond timestamp information to the second device, so that the seconddevice performs clock synchronization.

In an embodiment, the first protocol field may be an existing protocolfield, or may be a newly added protocol field (for example, a NEW field)in an existing protocol stack framework. The second protocol field mayalternatively be an existing protocol field, or may be a newly addedprotocol field (for example, a NEW field) in an existing protocol stackframework.

In an embodiment, when the first device is the user plane networkelement, and the second device is the terminal device, the firstprotocol field is a GTP field, and the second protocol field is aservice data protocol SDAP field or a PDCP field. When the first deviceis the terminal device, and the second device is the user plane networkelement, the first protocol field is an SDAP field or a PDCP field, andthe second protocol field is a GTP field.

According to a sixth aspect, this application further provides asynchronization method.

A second device receives a third packet from an access device, where thethird packet carries first timestamp information and second timestampinformation, the first timestamp information is a moment that is in anEthernet network and at which a first device sends a first packet, thesecond timestamp information is a moment that is in a mobile network andat which the first device sends the first packet, and the third packetis sent by the access device based on the first packet after the accessdevice receives the first packet from the first device. The seconddevice determines fifth timestamp information and sixth timestampinformation, where the fifth timestamp information is a moment that isin the Ethernet network and at which the second device receives thethird packet, and the sixth timestamp information is a moment that is inthe mobile network and at which the second device receives the thirdpacket. The second device sends a fourth packet to the access device,and determines seventh timestamp information and eighth timestampinformation, where the seventh timestamp information is a moment that isin the Ethernet network and at which the second device sends the fourthpacket to the access device, and the eighth timestamp information is amoment that is in the mobile network and at which the second devicesends the fourth packet to the access device. The second device receivesthird timestamp information and fourth timestamp information from theaccess device, where the third timestamp information is a moment that isin the Ethernet network and at which the first device receives a secondpacket, the fourth timestamp information is a moment that is in themobile network and at which the first device receives the second packet,and the second packet is sent by the access device to the first devicebased on the fourth packet. The second device determines a time offsetbetween the first device and the second device based on the firsttimestamp information, the second timestamp information, the sixthtimestamp information, the eighth timestamp information, the thirdtimestamp information, the fourth timestamp information, the fifthtimestamp information, and the seventh timestamp information, andperforms time synchronization based on the time offset. The first deviceis a user plane network element and the second device is a terminaldevice, or the first device is a terminal device and the second deviceis a user plane network element.

According to an embodiment, the second device calculates the time offsetbetween the first device and the second device by using timestampinformation of receiving and sending packets in the mobile network andtimestamp information of receiving and sending packets in the Ethernetnetwork, to perform time synchronization. In the method, impact of atransmission delay between the first device and the second device can beavoided, so that a time precision requirement of an industrial factorycan be met in a scenario in which the mobile network is connected to theEthernet network.

In an embodiment, a method in which the second device determines thetime offset between the first device and the second device based on thefirst timestamp information, the second timestamp information, the sixthtimestamp information, the eighth timestamp information, the thirdtimestamp information, the fourth timestamp information, the fifthtimestamp information, and the seventh timestamp information may be: Thesecond device determines a round-trip transmission delay differencebetween the first device and the second device based on the secondtimestamp information, the sixth timestamp information, the eighthtimestamp information, and the fourth timestamp information. The seconddevice determines the time offset between the first device and thesecond device based on the first timestamp information, the thirdtimestamp information, the fifth timestamp information, the seventhtimestamp information, and the round-trip transmission delay difference.

According to the method, the second device may determine the round-triptransmission delay difference between the first device and the seconddevice, to determine the time offset between the first device and thesecond device.

In an embodiment, a method in which the second device determines thetime offset between the first device and the second device based on thefirst timestamp information, the third timestamp information, the fifthtimestamp information, the seventh timestamp information, and theround-trip transmission delay difference may be: The second devicedetermines ninth timestamp information, where the ninth timestampinformation is a sum of the moment corresponding to the third timestampinformation and the round-trip transmission delay difference. Then, thesecond device determines the time offset between the first device andthe second device based on the first timestamp information, the fifthtimestamp information, the seventh timestamp information, and the ninthtimestamp information.

According to an embodiment, the second device can accurately determinethe time offset between the first device and the second device, so thatthe second device performs time synchronization based on the timeoffset.

In an embodiment, after the second device receives the third packet fromthe access device, the second device extracts the second timestampinformation carried in a second protocol field included in the thirdpacket.

In an embodiment, the second protocol field may be an existing protocolfield, or may be a newly added protocol field (for example, a NEW field)in an existing protocol stack framework.

In an embodiment, if the second protocol field is the existing protocolfield, when the second device is the terminal device, the secondprotocol field is a SDAP field or a PDCP field. When the second deviceis the user plane network element, the second protocol field is a GTPfield.

According to a seventh aspect, this application further provides asynchronization method.

A first device sends a first packet to an access device, where the firstpacket carries first timestamp information and second timestampinformation, the first timestamp information is a moment that is in anEthernet network and at which the first device sends the first packet,and the second timestamp information is a moment that is in a mobilenetwork and at which the first device sends the first packet. Then, thefirst device sends a second packet to the access device, where thesecond packet carries third timestamp information and fourth timestampinformation, the third timestamp information is a moment that is in theEthernet network and at which the first device sends the second packet,and the fourth timestamp information is a moment that is in the mobilenetwork and at which the first device sends the second packet. The firstdevice is a user plane network element and a second device is a terminaldevice, or the first device is a terminal device and a second device isa user plane network element.

According to an embodiment, the first device sends a packet to thesecond device, so that the second device calculates a frequency offsetbetween the first device and the second device by using time points ofreceiving and sending packets in the mobile network and time points ofreceiving and sending packets in the Ethernet network during packettransmission initiated by the first device, to perform frequencysynchronization. Impact of a transmission delay between the first deviceand the second device can be avoided, so that a time precisionrequirement of an industrial factory can be met in a scenario in whichthe mobile network is connected to the Ethernet network.

In an embodiment, that the first packet carries second timestampinformation may be: The first device uses a first protocol fieldincluded in the first packet to carry the second timestamp information.

According to the method, the first device can successfully transmit thesecond timestamp information to the access device, so that the accessdevice subsequently transmits the second timestamp information to thesecond device.

In an embodiment, the first protocol field may be an existing protocolfield, or may be a newly added protocol field (for example, a NEW field)in an existing protocol stack framework.

In an embodiment, when the first device is the user plane networkelement, the first protocol field is a general packet radio service GPRStunneling protocol GTP field. When the first device is the terminaldevice, the first protocol field is a service data protocol SDAP fieldor a data convergence protocol PDCP field.

In an embodiment, that the second packet carries fourth timestampinformation may be: The first device uses a second protocol fieldincluded in the second packet to carry the fourth timestamp information.

According to an embodiment, the first device can successfully transmitthe fourth timestamp information to the access device, so that theaccess device subsequently transmits the fourth timestamp information tothe second device.

In an embodiment, the second protocol field may be an existing protocolfield, or may be a newly added protocol field (for example, a NEW field)in an existing protocol stack framework.

In an embodiment, when the first device is the user plane networkelement, the second protocol field is a general packet radio serviceGPRS tunneling protocol GTP field. When the first device is the terminaldevice, the second protocol field is a service data protocol SDAP fieldor a data convergence protocol PDCP field.

According to an eighth aspect, this application further provides asynchronization method.

An access device receives a first packet from a first device, and sendsa third packet to a second device based on the first packet, where thefirst packet carries first timestamp information and second timestampinformation, the first timestamp information is a moment that is in anEthernet network and at which the first device sends the first packet,the second timestamp information is a moment that is in a mobile networkand at which the first device sends the first packet, and the thirdpacket carries the first timestamp information and the second timestampinformation. Then, the access device receives a second packet from thefirst device, and sends a fourth packet to the second device based onthe second packet, where the second packet carries third timestampinformation and fourth timestamp information, the third timestampinformation is a moment that is in the Ethernet network and at which thefirst device sends the second packet, the fourth timestamp informationis a moment that is in the mobile network and at which the first devicesends the second packet, and the fourth packet carries the thirdtimestamp information and the fourth timestamp information. The firstdevice is a user plane network element and the second device is aterminal device, or the first device is a terminal device and the seconddevice is a user plane network element.

According to an embodiment, the access device transmits timestampinformation required for clock synchronization to the first device andthe second device, to complete clock synchronization.

In an embodiment, a method in which the access device sends the thirdpacket to the second device based on the first packet may be: When theaccess device detects that a first protocol field included in the firstpacket includes the second timestamp information, the access deviceencapsulates the second timestamp information in a third protocol fieldincluded in the first packet to generate the third packet, and sends thethird packet to the second device.

According to an embodiment, the access device may successfully send thesecond timestamp information to the second device, so that the seconddevice performs clock synchronization.

In an embodiment, before the access device encapsulates the secondtimestamp information in the third protocol field included in the firstpacket, the access device extracts the second timestamp informationincluded in a first protocol field included in the first packet.

In an embodiment, the first protocol field may be an existing protocolfield, or may be a newly added protocol field (for example, a NEW field)in an existing protocol stack framework. The third protocol field mayalternatively be an existing protocol field, or may be a newly addedprotocol field (for example, a NEW field) in an existing protocol stackframework.

In an embodiment, when the first device is the user plane networkelement and the second device is the terminal device, the first protocolfield is a GTP field, and the third protocol field is a SDAP field or aPDCP field. When the first device is the terminal device and the seconddevice is the user plane network element, the first protocol field is anSDAP field or a PDCP field, and the third protocol field is a GTP field.

In an embodiment, a method in which the access device sends the fourthpacket to the second device based on the second packet may be: When theaccess device detects that a second protocol field included in thesecond packet includes the fourth timestamp information, the accessdevice encapsulates the fourth timestamp information in a fourthprotocol field in the second packet to generate the fourth packet, andsends the fourth packet to the second device.

According to the method, the access device may successfully send thefourth timestamp information to the second device, so that the seconddevice performs clock synchronization.

In an embodiment, before the access device encapsulates the fourthtimestamp information in the fourth protocol field included in thesecond packet, the access device extracts the second timestampinformation included in the second protocol field included in the secondpacket.

In an embodiment, the fourth protocol field may be an existing protocolfield, or may be a newly added protocol field (for example, a NEW field)in an existing protocol stack framework. The second protocol field mayalternatively be an existing protocol field, or may be a newly addedprotocol field (for example, a NEW field) in an existing protocol stackframework.

In an embodiment, when the first device is the user plane networkelement and the second device is the terminal device, the secondprotocol field is a GTP field, and the fourth protocol field is a SDAPfield or a PDCP field. When the first device is the terminal device andthe second device is the user plane network element, the second protocolfield is an SDAP field or a PDCP field, and the fourth protocol field isa GTP field.

According to a ninth aspect, this application further provides asynchronization method.

A second device receives a third packet from an access device, where thethird packet carries first timestamp information and second timestampinformation, the first timestamp information is a moment that is in anEthernet network and at which a first device sends a first packet to theaccess device, the second timestamp information is a moment that is in amobile network and at which the first device sends the first packet tothe access device, and the third packet is sent by the access device tothe second device based on the first packet.

The second device determines fifth timestamp information and sixthtimestamp information, where the fifth timestamp information is a momentthat is in the Ethernet network and at which the second device receivesthe third packet, and the sixth timestamp information is a moment thatis in the mobile network and at which the second device receives thethird packet. The second device receives a fourth packet from the accessdevice, where the fourth packet carries third timestamp information andfourth timestamp information, the third timestamp information is amoment that is in the Ethernet network and at which the first devicesends a second packet to the access device, the fourth timestampinformation is a moment that is in the mobile network and at which thefirst device sends the second packet to the access device, and thefourth packet is sent by the access device to the second device based onthe second packet. The second device determines seventh timestampinformation and eighth timestamp information, where the seventhtimestamp information is a moment that is in the Ethernet network and atwhich the second device receives the fourth packet, and the eighthtimestamp information is a moment that is in the mobile network and atwhich the second device receives the fourth packet. The second devicedetermines a frequency offset between the first device and the seconddevice based on the first timestamp information, the second timestampinformation, the third timestamp information, the fourth timestampinformation, the fifth timestamp information, the sixth timestampinformation, the seventh timestamp information, and the eighth timestampinformation, and performs frequency synchronization based on thefrequency offset. The first device is a user plane network element andthe second device is a terminal device, or the first device is aterminal device and the second device is a user plane network element.

According to an embodiment, the second device calculates the frequencyoffset between the first device and the second device by using timepoints of receiving and sending packets in the mobile network and timepoints of receiving and sending packets in the Ethernet network duringpacket transmission initiated by the first device, to perform frequencysynchronization. In the method, impact of a transmission delay betweenthe first device and the second device can be avoided, so that a clockprecision requirement of an industrial factory can be met in a scenarioin which the mobile network is connected to the Ethernet network.

In an embodiment, a method in which the second device determines thefrequency offset between the first device and the second device based onthe first timestamp information, the second timestamp information, thethird timestamp information, the fourth timestamp information, the fifthtimestamp information, the sixth timestamp information, the seventhtimestamp information, and the eighth timestamp information may be: Thesecond device determines a first difference between the momentcorresponding to the sixth timestamp information and the momentcorresponding to the second timestamp information, and determines asecond difference between the moment corresponding to the eighthtimestamp information and the moment corresponding to the fourthtimestamp information. The second device determines the frequency offsetbetween the first device and the second device based on the firsttimestamp information, the third timestamp information, the fifthtimestamp information, the seventh timestamp information, the firstdifference, and the second difference.

According to the method, the second device can accurately determine thefrequency offset between the first device and the second device.

In an embodiment, a method in which the second device determines thefrequency offset between the first device and the second device based onthe first timestamp information, the third timestamp information, thefifth timestamp information, the seventh timestamp information, thefirst difference, and the second difference may be:

The second device determines a value relationship between the firstdifference and the second difference.

When the second device determines that the second difference is lessthan the first difference, the second device determines that thefrequency offset is a quotient of a first value and a second value,where the first value is a difference between the moment correspondingto the third timestamp information and the moment corresponding to thefirst timestamp information, the second value is a value obtained byadding a third value to a difference between the moment corresponding tothe seventh timestamp information and the moment corresponding to thefifth timestamp information, the third value is a product value of afourth value and a fifth value, the fourth value is a value obtained bysubtracting the second difference from the first difference, and thefifth value is a value obtained by dividing the difference between themoment corresponding to the seventh timestamp information and the momentcorresponding to the fifth timestamp information by a difference betweenthe moment corresponding to the eighth timestamp information and themoment corresponding to the sixth timestamp information.

When the second device determines that the second difference is greaterthan the first difference, the second device determines that thefrequency offset is a quotient of a first value and a sixth value, wherethe sixth value is a value obtained by subtracting a seventh value froma difference between the moment corresponding to the seventh timestampinformation and the moment corresponding to the fifth timestampinformation, the seventh value is a product value of an eighth value anda fifth value, and the eighth value is a value obtained by subtractingthe first difference from the second difference.

According to the method, the second device can accurately determine thefrequency offset between the first device and the second device, toperform frequency synchronization.

According to a tenth aspect, this application further provides asynchronization method.

After determining first timestamp information, a first device sends afirst packet to an access device, where the first packet carries thefirst timestamp information, the first timestamp information is adifference between a moment corresponding to second timestampinformation and a moment corresponding to third timestamp information,the second timestamp information is master clock information in anEthernet network, and the third timestamp information is master clockinformation in a mobile network. The first device is a user planenetwork element and a second device is a terminal device, or the firstdevice is a terminal device and a second device is a user plane networkelement.

According to the method, the first device determines a differencebetween the master clock information in the mobile network and themaster clock information in the Ethernet network, and sends thedifference to the second device, so that the second device directlycompletes clock synchronization by using the difference between themaster clock information. In the method, impact of a transmission delaybetween the first device and the second device can be avoided, so that atime precision requirement of an industrial factory can be met in ascenario in which the mobile network is connected to the Ethernetnetwork.

In an embodiment, that the first packet carries the first timestampinformation may be: The first device uses a first protocol fieldincluded in the first packet to carry the first timestamp information.

According to an embodiment, the first device can successfully transmitthe first timestamp information to the access device, so that the accessdevice subsequently transmits the first timestamp information to thesecond device.

In an embodiment, the first protocol field may be an existing protocolfield, or may be a newly added protocol field (for example, a NEW field)in an existing protocol stack framework.

In an embodiment, when the first device is the user plane networkelement, the first protocol field is a general packet radio service(GPRS) tunneling protocol (GTP) field. When the first device is theterminal device, the first protocol field is a service data protocol(SDAP) field or a data convergence protocol (PDCP) field.

In an embodiment, the first device receives a second packet from theaccess device, where the second packet is used to notify the firstdevice that time synchronization has been completed.

According to an embodiment, the first device can terminate transmissionof a packet after a third packet in an existing synchronizationprocedure by identifying that time synchronization is completed, therebyreducing resource consumption.

According to an eleventh aspect, this application further provides asynchronization method.

An access device receives a first packet from a first device, and sendsa third packet to a second device based on the first packet, where thefirst packet carries first timestamp information, the first timestampinformation is a difference between a moment corresponding to secondtimestamp information and a moment corresponding to third timestampinformation, the second timestamp information is master clockinformation in an Ethernet network, the third timestamp information ismaster clock information in a mobile network, and the third packetcarries the first timestamp information. The first device is a userplane network element and the second device is a terminal device, or thefirst device is a terminal device and the second device is a user planenetwork element.

According to an embodiment, the access device transmits timestampinformation required for clock synchronization to the first device andthe second device, to complete clock synchronization.

In an embodiment, when the access device detects that a first protocolfield included in the first packet includes the first timestampinformation, the access device encapsulates the first timestampinformation in a second protocol field included in the first packet togenerate the third packet, and sends the third packet to the seconddevice.

According to an embodiment, the access device may successfully send thefirst timestamp information to the second device, so that the seconddevice performs clock synchronization.

In an embodiment, before the access device encapsulates the firsttimestamp information in the second protocol field included in the firstpacket, the access device extracts the second timestamp informationincluded in the first protocol field included in the first packet.

In an embodiment, the first protocol field may be an existing protocolfield, or may be a newly added protocol field (for example, a NEW field)in an existing protocol stack framework. The second protocol field mayalternatively be an existing protocol field, or may be a newly addedprotocol field (for example, a NEW field) in an existing protocol stackframework.

In an embodiment, when the first device is the user plane networkelement and the second device is the terminal device, the first protocolfield is a GTP field, and the second protocol field is a SDAP field or aPDCP field. When the first device is the terminal device and the seconddevice is the user plane network element, the first protocol field is anSDAP field or a PDCP field, and the second protocol field is a GTPfield.

In an embodiment, the access device receives a second packet from thesecond device, and forwards the second packet to the first device, wherethe second packet is used to notify the first device that timesynchronization is completed.

According to an embodiment, the first device can terminate transmissionof a packet after a third packet in an existing synchronizationprocedure by identifying that time synchronization is completed, therebyreducing resource consumption.

According to a twelfth aspect, this application further provides asynchronization method.

A second device receives a third packet from an access device, where thethird packet carries first timestamp information, the first timestampinformation is a difference between a moment corresponding to secondtimestamp information and a moment corresponding to third timestampinformation, the second timestamp information is master clockinformation in an Ethernet network, the third timestamp information ismaster clock information in a mobile network, the third packet is sentby the access device based on a first packet, and the first packet issent by a first device to the access device. The first device is a userplane network element and the second device is a terminal device, or thefirst device is a terminal device and the second device is a user planenetwork element. Then, the second device determines fourth timestampinformation, and completes time synchronization by adding the differencecorresponding to the first timestamp information to a momentcorresponding to the fourth timestamp information, where the fourthtimestamp information is a moment that is in the mobile network and atwhich the second device receives the third packet.

According to an embodiment, the second device directly completes clocksynchronization by using a difference between the master clockinformation. In the method, impact of a transmission delay between thefirst device and the second device can be avoided, so that a timeprecision requirement of an industrial factory can be met in a scenarioin which the mobile network is connected to the Ethernet network.

In an embodiment, after the second device receives the third packet fromthe access device, the second device extracts the first timestampinformation carried in a second protocol field included in the thirdpacket.

In an embodiment, the second protocol field may be an existing protocolfield, or may be a newly added protocol field (for example, a NEW field)in an existing protocol stack framework.

In an embodiment, when the second device is the terminal device, thesecond protocol field is a service data protocol SDAP field or a dataconvergence protocol PDCP field. When the second device is the userplane network element, the second protocol field is a general packetradio service GPRS tunneling protocol GTP field.

In an embodiment, the second device sends a second packet to the accessdevice, where the second packet is used to notify the first device thattime synchronization is completed.

According to an embodiment, the access device subsequently forwards thesecond packet to the first device, so that the first device canterminate transmission of a packet after the third packet in an existingsynchronization procedure by identifying that time synchronization iscompleted, thereby reducing resource consumption.

According to a thirteenth aspect, this application further provides afirst device. The first device has a function of implementing behaviorof the first device in the method example in the first aspect, thefourth aspect, the seventh aspect, or the tenth aspect. The function maybe implemented by hardware, or may be implemented by hardware executingcorresponding software. The hardware or software includes one or moremodules corresponding to the foregoing function.

In an embodiment, a structure of the first device includes a sendingunit, a processing unit, and a receiving unit. These units may performcorresponding functions in the method example in the first aspect, thefourth aspect, the seventh aspect, or the tenth aspect. For details,refer to the detailed descriptions in the method example. Details arenot described herein again.

In an embodiment, a structure of the first device includes atransceiver, a processor, and a memory. The transceiver is configuredto: receive and send data, and communicate and interact with anotherdevice in a communications system. The processor is configured tosupport the first device in performing a corresponding function in themethod in the first aspect, the fourth aspect, the seventh aspect, orthe tenth aspect. The memory is coupled to the processor, and the memorystores a program instruction and data that are necessary for the firstdevice.

According to a fourteenth aspect, this application further provides anaccess device. The access device has a function of implementing behaviorof the access device in the method example in the second aspect, thefifth aspect, the eighth aspect, or the eleventh aspect. The functionmay be implemented by hardware, or may be implemented by hardwareexecuting corresponding software. The hardware or software includes oneor more modules corresponding to the foregoing function.

In an embodiment, a structure of the access device includes a sendingunit and a receiving unit. These units may perform correspondingfunctions in the method example in the second aspect, the fifth aspect,the eighth aspect, or the eleventh aspect. For details, refer to thedetailed descriptions in the method example. Details are not describedherein again.

In an embodiment, a structure of the access device includes atransceiver, a processor, and a memory. The transceiver is configuredto: receive and send data, and communicate and interact with anotherdevice in a communications system. The processor is configured tosupport the access device in performing a corresponding function in themethod in the second aspect, the fifth aspect, the eighth aspect, or theeleventh aspect. The memory is coupled to the processor, and the memorystores a program instruction and data that are necessary for the accessdevice.

According to a fifteenth aspect, this application further provides asecond device. The second device has a function of implementing behaviorof the second device in the method example in the third aspect, thesixth aspect, the ninth aspect, or the twelfth aspect. The function maybe implemented by hardware, or may be implemented by hardware executingcorresponding software. The hardware or software includes one or moremodules corresponding to the foregoing function.

In an embodiment, a structure of the second device includes a receivingunit, a processing unit, and a sending unit. These units may performcorresponding functions in the method example in the third aspect, thesixth aspect, the ninth aspect, or the twelfth aspect. For details,refer to the detailed descriptions in the method example. Details arenot described herein again.

In an embodiment, a structure of the second device includes atransceiver, a processor, and a memory. The transceiver is configuredto: receive and send data, and communicate and interact with anotherdevice in a communications system. The processor is configured tosupport the second device in performing a corresponding function in themethod in the third aspect, the sixth aspect, the ninth aspect, or thetwelfth aspect. The memory is coupled to the processor, and the memorystores a program instruction and data that are necessary for the seconddevice.

According to a sixteenth aspect, this application further provides acommunications system. The communications system may include the firstdevice, the access device, the second device, and the like mentioned inthe foregoing designs.

According to a seventeenth aspect, this application further provides acomputer storage medium. The computer storage medium stores a computerexecutable instruction, and when the computer executable instruction isinvoked by a computer, the computer is enabled to perform any one of theforegoing methods.

According to an eighteenth aspect, this application further provides acomputer program product including an instruction. When the computerprogram product is run on a computer, the computer is enabled to performany one of the foregoing methods.

According to a nineteenth aspect, this application further provides achip. The chip is connected to a memory, and is configured to: read andexecute a program instruction stored in the memory, to implement any oneof the foregoing methods.

According to a twentieth aspect, this application further provides asynchronization method.

First, after receiving a first packet from a third device, a firstdevice determines first timestamp information, and sends a first packetto a second device by using an access device, where the first timestampinformation is a moment that is in a mobile network and at which thefirst device receives the first packet. Then, after receiving a secondpacket from the third device, the first device sends a third packet tothe access device based on the second packet, where the third packetcarries the first timestamp information. Subsequently, after receiving afourth packet from the access device, the first device sends the fourthpacket to the third device, and determines second timestamp information,where the second timestamp information is a moment that is in the mobilenetwork and at which the first device sends the fourth packet to thethird device. After receiving a fifth packet from the third device, thefirst device determines third timestamp information, and sends a sixthpacket to the access device based on the fifth packet, where the sixthpacket carries the second timestamp information, and the third timestampinformation is a moment that is in the mobile network and at which thefirst device receives the fifth packet. Finally, after receiving aseventh packet from the third device, the first device sends an eighthpacket to the access device, where the seventh packet carries fourthtimestamp information, the fourth timestamp information is a moment thatis in an Ethernet network and at which the third device sends the fifthpacket to the first device, and the eighth packet carries the thirdtimestamp information and the fourth timestamp information. The firstdevice is a user plane network element and the second device is aterminal device, or the first device is a terminal device and the seconddevice is a user plane network element.

According to an embodiment, impact of a transmission delay between thefirst device and the second device can be avoided, so that a timeprecision requirement of an industrial factory can be met in a scenarioin which the mobile network is connected to the Ethernet network.

In an embodiment, that the third packet carries the first timestampinformation may be: The first device uses a first protocol fieldincluded in the third packet to carry the first timestamp information.In this way, the first device can successfully transmit the firsttimestamp information to the access device.

In an embodiment, the first protocol field may be an existing protocolfield, or may be a newly added protocol field (for example, a NEW field)in an existing protocol stack framework.

In an embodiment, when the first device is the terminal device, thefirst protocol field is an SDAP field or a PDCP field. Alternatively,when the first device is the user plane network element, the firstprotocol field is a GTP field.

In an embodiment, that the sixth packet carries the second timestampinformation may be: The first device uses a second protocol fieldincluded in the sixth packet to carry the second timestamp information.In this way, the first device can successfully transmit the secondtimestamp information to the access device.

In an embodiment, the second protocol field may be an existing protocolfield, or may be a newly added protocol field (for example, a NEW field)in an existing protocol stack framework.

In an embodiment, when the first device is the terminal device, thesecond protocol field is an SDAP field or a PDCP field. Alternatively,when the second device is the user plane network element, the secondprotocol field is a GTP field.

In an embodiment, that the eighth packet carries the third timestampinformation may be: The first device uses a third protocol fieldincluded in the eighth packet to carry the third timestamp information.In this way, the first device can successfully transmit the thirdtimestamp information to the access device.

In an embodiment, the third protocol field may be an existing protocolfield, or may be a newly added protocol field (for example, a NEW field)in an existing protocol stack framework.

In an embodiment, when the first device is the terminal device, thethird protocol field is an SDAP field or a PDCP field. Alternatively,when the second device is the user plane network element, the thirdprotocol field is a GTP field.

According to a twenty-first aspect, this application further provides asynchronization method.

After receiving a first packet from a first device, an access deviceforwards the first packet to a second device. After receiving a thirdpacket from the first device, the access device sends a ninth packet tothe second device based on the third packet, where the third packetcarries first timestamp information, the ninth packet carries the firsttimestamp information, and the first timestamp information is a momentthat is in a mobile network and at which the first device receives thefirst packet from a third device. After receiving a fourth packet fromthe second device, the access device sends the fourth packet to thefirst device. After receiving a sixth packet from the first device, theaccess device sends a tenth packet to the second device based on thesixth packet, where the sixth packet is sent by the first device to theaccess device based on a fifth packet after the first device receivesthe fifth packet from the third device, the sixth packet carries secondtimestamp information, the second timestamp information is a moment thatis in the mobile network and at which the first device sends the fourthpacket to the third device after receiving the fourth packet from theaccess device, and the tenth packet carries the second timestampinformation. The access device receives an eighth packet from the firstdevice, and sends an eleventh packet to the second device based on theeighth packet, where the eighth packet carries third timestampinformation and fourth timestamp information, the third timestampinformation is a moment that is in the mobile network and at which thefirst device receives the fifth packet from the third device, the fourthtimestamp information is a moment that is in an Ethernet network and atwhich the third device sends the fifth packet to the first device, andthe eleventh packet carries the third timestamp information and thefourth timestamp information. The first device is a user plane networkelement and the second device is a terminal device, or the first deviceis a terminal device and the second device is a user plane networkelement.

According to the method, the access device transmits timestampinformation required for clock synchronization to the first device andthe second device, to complete clock synchronization.

In an embodiment, that the access device sends a ninth packet to thesecond device based on the third packet may be: When detecting that afirst protocol field included in the third packet carries the firsttimestamp information, the access device encapsulates the firsttimestamp information in a fourth protocol field in the third packet togenerate the ninth packet, and sends the ninth packet to the seconddevice. In this way, the access device may transmit the first timestampinformation to the second device.

In an embodiment, the first protocol field may be an existing protocolfield, or may be a newly added protocol field (for example, a NEW field)in an existing protocol stack framework. The fourth protocol field mayalternatively be an existing protocol field, or may be a newly addedprotocol field (for example, a NEW field) in an existing protocol stackframework.

In an embodiment, when the first device is the terminal device, thefirst protocol field is an SDAP field or a PDCP field, and the fourthprotocol field is a GTP field. Alternatively, when the first device isthe user plane network element, the first protocol field is a GTP field,and the fourth protocol field is an SDAP field or a PDCP field.

In an embodiment, that the access device sends a tenth packet to thesecond device based on the sixth packet may be: When detecting that asecond protocol field included in the sixth packet carries the secondtimestamp information, the access device encapsulates the secondtimestamp information in a fifth protocol field in the sixth packet togenerate the tenth packet, and sends the tenth packet to the seconddevice. In this way, the access device may transmit the second timestampinformation to the second device.

In an embodiment, the second protocol field may be an existing protocolfield, or may be a newly added protocol field (for example, a NEW field)in an existing protocol stack framework. The fifth protocol field mayalternatively be an existing protocol field, or may be a newly addedprotocol field (for example, a NEW field) in an existing protocol stackframework.

In an embodiment, when the first device is the terminal device, thesecond protocol field is an SDAP field or a PDCP field, and the fifthprotocol field is a GTP field. Alternatively, when the first device isthe user plane network element, the second protocol field is a GTPfield, and the fifth protocol field is an SDAP field or a PDCP field.

In an embodiment, that the access device sends an eleventh packet to thesecond device based on the eighth packet may be: When detecting that athird protocol field included in the eighth packet carries the thirdtimestamp information, the access device encapsulates the thirdtimestamp information in a sixth protocol field in the eighth packet togenerate the eleventh packet, and sends the eleventh packet to thesecond device. In this way, the access device may transmit the thirdtimestamp information to the second device.

In an embodiment, the third protocol field may be an existing protocolfield, or may be a newly added protocol field (for example, a NEW field)in an existing protocol stack framework. The sixth protocol field mayalternatively be an existing protocol field, or may be a newly addedprotocol field (for example, a NEW field) in an existing protocol stackframework.

In an embodiment, when the first device is the terminal device, thethird protocol field is an SDAP field or a PDCP field, and the sixthprotocol field is a GTP field. Alternatively, when the first device isthe user plane network element, the third protocol field is a GTP field,and the sixth protocol field is an SDAP field or a PDCP field.

According to a twenty-second aspect, this application further provides asynchronization method.

First, after receiving a first packet from an access device, a seconddevice sends the first packet to a fourth device, and determines fifthtimestamp information, where the fifth timestamp information is a momentthat is in a mobile network and at which the second device sends thefirst packet to the fourth device. Then, after receiving a ninth packetfrom the access device, the second device sends a twelfth packet to thefourth device based on the ninth packet, where the ninth packet carriesfirst timestamp information, and the first timestamp information is amoment that is in the mobile network and at which a first devicereceives the first packet from a third device. The second devicereceives a fourth packet from the fourth device, determines sixthtimestamp information, and sends the fourth packet to the access device,where the sixth timestamp information is a moment that is in the mobilenetwork and at which the second device receives the fourth packet. Thesecond device receives a tenth packet from the access device, where thetenth packet carries second timestamp information, and the secondtimestamp information is a moment that is in the mobile network and atwhich the first device sends the fourth packet to the third device afterthe access device sends the fourth packet to the first device. Thesecond device sends a thirteenth packet to the fourth device, anddetermines seventh timestamp information, where the seventh timestampinformation is a moment that is in the mobile network and at which thesecond device sends the thirteenth packet to the fourth device. Thesecond device receives an eleventh packet from the access device, wherethe eleventh packet carries third timestamp information and fourthtimestamp information, the third timestamp information is a moment thatis in the mobile network and at which the first device receives a fifthpacket from the third device, and the fourth timestamp information is amoment that is in an Ethernet network and at which the third devicesends the fifth packet to the first device. Finally, the second devicedetermines eighth timestamp information based on the first timestampinformation, the second timestamp information, the third timestampinformation, the fourth timestamp information, the fifth timestampinformation, the sixth timestamp information, and the seventh timestampinformation. The second device sends the eighth timestamp information tothe fourth device, so that the fourth device performs timesynchronization based on the eighth timestamp information.

According to an embodiment, impact of a transmission delay between thefirst device and the second device can be avoided, so that a timeprecision requirement of an industrial factory can be met in a scenarioin which the mobile network is connected to the Ethernet network.

In an embodiment, after receiving the ninth packet from the accessdevice, the second device extracts the first timestamp informationcarried in a fourth protocol field included in the ninth packet. In thisway, the second device may subsequently determine the eighth timestampinformation by using the first timestamp information.

In an embodiment, the fourth protocol field may be an existing protocolfield, or may be a newly added protocol field (for example, a NEW field)in an existing protocol stack framework.

In an embodiment, when the second device is the user plane networkelement, the fourth protocol field is a GTP field. Alternatively, whenthe second device is the terminal device, the fourth protocol field isan SDAP field or a PDCP field.

In an embodiment, after receiving the tenth packet from the accessdevice, the second device extracts the second timestamp informationcarried in a fifth protocol field included in the tenth packet. In thisway, the second device may subsequently determine the eighth timestampinformation by using the second timestamp information.

In an embodiment, the fifth protocol field may be an existing protocolfield, or may be a newly added protocol field (for example, a NEW field)in an existing protocol stack framework.

In an embodiment, when the second device is the user plane networkelement, the fifth protocol field is a GTP field. Alternatively, whenthe second device is the terminal device, the fifth protocol field is anSDAP field or a PDCP field.

In an embodiment, after receiving the eleventh packet from the accessdevice, the second device extracts the third timestamp informationcarried in a sixth protocol field included in the eleventh packet. Inthis way, the second device may subsequently determine the eighthtimestamp information by using the third timestamp information.

In an embodiment, the sixth protocol field may be an existing protocolfield, or may be a newly added protocol field (for example, a NEW field)in an existing protocol stack framework.

In an embodiment, when the second device is the user plane networkelement, the sixth protocol field is a GTP field. Alternatively, whenthe second device is the terminal device, the sixth protocol field is anSDAP field or a PDCP field.

According to a twenty-third aspect, this application further provides asynchronization method.

First, a first device sends a first packet to an access device, anddetermines first timestamp information and second timestamp information,where the first timestamp information is a moment that is in an Ethernetnetwork and at which the first device sends the first packet, and thesecond timestamp information is a moment that is in a mobile network andat which the first device sends the first packet. The first device sendsa second packet to the access device, where the second packet carriesthe first timestamp information and the second timestamp information.Then, the first device receives a third packet from the access device,and determines third timestamp information, where the third timestampinformation is a moment that is in the Ethernet network and at which thefirst device receives the third packet. The first device sends a fourthpacket to the access device, and determines fourth timestampinformation, where the fourth timestamp information is a moment that isin the Ethernet network and at which the first device sends the fourthpacket, and the fourth packet carries the third timestamp information.Finally, the first device sends a fifth packet to the access device,where the fifth packet carries the fourth timestamp information. Thefirst device is a user plane network element and a second device is aterminal device, or the first device is a terminal device and a seconddevice is a user plane network element.

According to an embodiment, impact of a transmission delay between thefirst device and the second device can be avoided, so that a timeprecision requirement of an industrial factory can be met in a scenarioin which the mobile network is connected to the Ethernet network.

In an embodiment, that the second packet carries the second timestampinformation may be: The first device uses a first protocol fieldincluded in the second packet to carry the second timestamp information.In this way, the first device can successfully transmit the secondtimestamp information to the access device.

In an embodiment, the first protocol field may be an existing protocolfield, or may be a newly added protocol field (for example, a NEW field)in an existing protocol stack framework.

In an embodiment, when the first device is the terminal device, thefirst protocol field is an SDAP field or a PDCP field. Alternatively,when the first device is the user plane network element, the firstprotocol field is a GTP field.

According to a twenty-fourth aspect, this application further provides asynchronization method.

After receiving a first packet from a first device, an access deviceforwards the first packet to a second device. After receiving a secondpacket from the first device, the access device sends a sixth packet tothe second device based on the second packet, where the second packetcarries first timestamp information and second timestamp information,the first timestamp information is a moment that is in an Ethernetnetwork and at which the first device sends the first packet to theaccess device, the second timestamp information is a moment that is in amobile network and at which the first device sends the first packet tothe access device, and the sixth packet carries the first timestampinformation and the second timestamp information. After receiving athird packet from the second device, the access device forwards thethird packet to the first device. After receiving a fourth packet fromthe first device, the access device forwards the fourth packet to thesecond device, where the fourth packet carries third timestampinformation, and the third timestamp information is a moment that is inthe Ethernet network and at which the first device receives the thirdpacket sent by the access device. After receiving a fifth packet fromthe first device, the access device forwards the fifth packet to thesecond device, where the fifth packet carries fourth timestampinformation, and the fourth timestamp information is a moment that is inthe Ethernet network and at which the first device sends the fourthpacket to the access device. The first device is a user plane networkelement and the second device is a terminal device, or the first deviceis a terminal device and the second device is a user plane networkelement.

According to the method, the access device transmits timestampinformation required for clock synchronization to the first device andthe second device, to complete clock synchronization.

In an embodiment, that the access device sends a sixth packet to thesecond device based on the second packet may be: When detecting that afirst protocol field included in the second packet carries the secondtimestamp information, the access device encapsulates the secondtimestamp information in a second protocol field in the second packet togenerate the sixth packet, and sends the sixth packet to the seconddevice.

In an embodiment, the first protocol field may be an existing protocolfield, or may be a newly added protocol field (for example, a NEW field)in an existing protocol stack framework. The second protocol field mayalternatively be an existing protocol field, or may be a newly addedprotocol field (for example, a NEW field) in an existing protocol stackframework.

In an embodiment, when the first device is the terminal device, thefirst protocol field is an SDAP field or a PDCP field, and the secondprotocol field is a GTP field. Alternatively, when the first device is auser plane network element, the first protocol field is a GTP field, andthe second protocol field is an SDAP field or a PDCP field.

According to a twenty-fifth aspect, this application further provides asynchronization method.

A second device receives a first packet from an access device, anddetermines fifth timestamp information and sixth timestamp information,where the fifth timestamp information is a moment that is in an Ethernetnetwork and at which the second device receives the first packet, andthe sixth timestamp information is a moment that is in a mobile networkand at which the second device receives the first packet. The seconddevice receives a sixth packet from the access device, where the sixthpacket carries first timestamp information and second timestampinformation, the first timestamp information is a moment that is in theEthernet network and at which a first device sends the first packet tothe access device, and the second timestamp information is a moment thatis in the mobile network and at which the first device sends the firstpacket to the access device. The second device sends a third packet tothe access device, and determines seventh timestamp information, wherethe seventh timestamp information is a moment that is in the Ethernetnetwork and at which the second device sends the third packet. Thesecond device receives a fourth packet from the access device, anddetermines eighth timestamp information, where the eighth timestampinformation is a moment that is in the Ethernet network and at which thesecond device receives the fourth packet, the fourth packet carriesthird timestamp information, and the third timestamp information is amoment that is in the Ethernet network and at which the first devicereceives the third packet after the access device receives the thirdpacket from the second device and forwards the third packet to the firstdevice. The second device receives a fifth packet from the accessdevice, where the fifth packet carries fourth timestamp information, andthe fourth timestamp information is a moment that is in the Ethernetnetwork and at which the first device sends the fourth packet to theaccess device. The second device determines a time offset between thefirst device and the second device based on the first timestampinformation, the second timestamp information, the third timestampinformation, the fourth timestamp information, the fifth timestampinformation, the sixth timestamp information, the seventh timestampinformation, and the eighth timestamp information, and performs timesynchronization based on the time offset. The first device is a userplane network element and the second device is a terminal device, or thefirst device is a terminal device and the second device is a user planenetwork element.

In an embodiment, impact of a transmission delay between the firstdevice and the second device can be avoided, so that a time precisionrequirement of an industrial factory can be met in a scenario in whichthe mobile network is connected to the Ethernet network.

In an embodiment, that the second device determines a time offsetbetween the first device and the second device based on the firsttimestamp information, the second timestamp information, the thirdtimestamp information, the fourth timestamp information, the fifthtimestamp information, the sixth timestamp information, the seventhtimestamp information, and the eighth timestamp information may be: Thesecond device determines ninth timestamp information based on the secondtimestamp information, the third timestamp information, the sixthtimestamp information, the seventh timestamp information, and the eighthtimestamp information. The second device deletes the fourth timestampinformation, and determines, based on the ninth timestamp information,the moment that is in the Ethernet network and at which the first devicesends the fourth packet to the access device. The second devicedetermines the time offset between the first device and the seconddevice based on the first timestamp information, the third timestampinformation, the fifth timestamp information, the seventh timestampinformation, the eighth timestamp information, and the ninth timestampinformation.

According to an embodiment, the second device can accurately determinethe time offset between the first device and the second device.

In an embodiment, after receiving the sixth packet from the accessdevice, the second device extracts the second timestamp informationcarried in a second protocol field included in the sixth packet.

In an embodiment, the second protocol field may be an existing protocolfield, or may be a newly added protocol field (for example, a NEW field)in an existing protocol stack framework.

In an embodiment, when the second device is the user plane networkelement, the second protocol field is a GTP field. Alternatively, whenthe second device is the terminal device, the second protocol field isan SDAP field or a PDCP field.

According to a twenty-sixth aspect, this application further provides asynchronization method.

First, after receiving a first packet from a third device, a firstdevice sends the first packet to a second device by using an accessdevice, and determines first timestamp information, where the firsttimestamp information is a moment that is in a mobile network and atwhich the first device receives the first packet. Then, after receivinga second packet from the access device, the first device sends a thirdpacket to the third device, where the second packet carries secondtimestamp information and third timestamp information, the secondtimestamp information is a moment that is in the mobile network and atwhich the second device sends the first packet to a fourth device afterreceiving the first packet, and the third timestamp information is amoment that is in the mobile network and at which the second devicereceives a fifth packet from the fourth device. The first devicedetermines fourth timestamp information, where the fourth timestampinformation is a moment that is in the mobile network and at which thefirst device sends the third packet. Subsequently, the first devicereceives a sixth packet from the third device, where the sixth packetcarries fifth timestamp information, and the fifth timestamp informationis a moment that is in an Ethernet network and at which the third devicereceives the third packet sent by the first device. Finally, the firstdevice determines sixth timestamp information based on the firsttimestamp information, the second timestamp information, the thirdtimestamp information, the fourth timestamp information, and the fifthtimestamp information, and forwards the sixth timestamp information tothe second device by using the access device. The first device is a userplane network element and the second device is a terminal device, or thefirst device is a terminal device and the second device is a user planenetwork element.

In an embodiment, impact of a transmission delay between the firstdevice and the second device can be avoided, so that a time precisionrequirement of an industrial factory can be met in a scenario in whichthe mobile network is connected to the Ethernet network.

In an embodiment, that the first device determines sixth timestampinformation based on the first timestamp information, the secondtimestamp information, the third timestamp information, the fourthtimestamp information, and the fifth timestamp information may be: Thefirst device determines a round-trip transmission delay differencebetween the first device and the second device based on the firsttimestamp information, the second timestamp information, the thirdtimestamp information, and the fourth timestamp information. The firstdevice calculates a sum of the moment corresponding to the fifthtimestamp information and the round-trip transmission delay difference,to obtain the sixth timestamp information.

According to an embodiment, the first device may accurately determinethe sixth timestamp information, so that the fourth device calculates atime offset between the third device and the fourth device based on thesixth timestamp information and time points of receiving and sendingpackets in the Ethernet network, to perform time synchronization.

In an embodiment, after receiving the second packet from the accessdevice, the first device extracts the second timestamp information andthe third timestamp information that are carried in a first protocolfield included in the second packet. In this way, the first device cantransmit the second timestamp information and the third timestampinformation to the access device.

In an embodiment, the first protocol field may be an existing protocolfield, or may be a newly added protocol field (for example, a NEW field)in an existing protocol stack framework.

In an embodiment, when the first device is the user plane networkelement, the first protocol field is a GTP field. Alternatively, whenthe first device is the terminal device, the first protocol field is anSDAP field or a PDCP field.

According to a twenty-seventh aspect, this application further providesa synchronization method.

First, after receiving a first packet from a first device, an accessdevice sends the first packet to a second device. Then, the accessdevice receives a fourth packet from the second device, where the fourthpacket carries second timestamp information and third timestampinformation, the second timestamp information is a moment that is in amobile network and at which the second device sends the first packet toa fourth device after receiving the first packet, the fourth packet issent by the second device to the access device based on a fifth packetafter the second device receives the fifth packet from the fourthdevice, and the third timestamp information is a moment that is in themobile network and at which the second device receives the fifth packet,Subsequently, the access device sends a second packet to the firstdevice, where the second packet carries the second timestamp informationand the third timestamp information. Finally, the access device receivessixth timestamp information from the first device, and sends the sixthtimestamp information to the second device. The first device is a userplane network element and the second device is a terminal device, or thefirst device is a terminal device and the second device is a user planenetwork element.

According to an embodiment, the access device transmits timestampinformation required for clock synchronization to the first device andthe second device, to complete clock synchronization.

In an embodiment, that the access device sends a second packet to thefirst device may be: When detecting that a second protocol fieldincluded in the fourth packet carries the second timestamp informationand the third timestamp information, the access device encapsulates thesecond timestamp information and the third timestamp information in afirst protocol field included in the fourth packet to generate thesecond packet, and sends the second packet to the first device. In thisway, the access device can transmit the second timestamp information andthe third timestamp information to the second device.

In an embodiment, the second protocol field may be an existing protocolfield, or may be a newly added protocol field (for example, a NEW field)in an existing protocol stack framework. The second protocol field mayalternatively be an existing protocol field, or may be a newly addedprotocol field (for example, a NEW field) in an existing protocol stackframework.

In an embodiment, when the first device is the user plane networkelement, the second protocol field is an SDAP field or a PDCP field, andthe first protocol field is a GTP field. Alternatively, when the firstdevice is the terminal device, the second protocol field is a GTP field,and the first protocol field is an SDAP field or a PDCP field.

According to a twenty-eighth aspect, this application further provides asynchronization method.

First, after receiving a first packet from an access device, a seconddevice sends the first packet to a fourth device, and determines secondtimestamp information, where the second timestamp information is amoment that is in a mobile network and at which the second device sendsthe first packet. Then, the second device receives a fifth packet fromthe fourth device, and determines third timestamp information, where thethird timestamp information is a moment that is in the mobile networkand at which the second device receives the fifth packet. Subsequently,the second device sends a fourth packet to the access device, where thefourth packet carries the second timestamp information and the thirdtimestamp information. Finally, the second device receives sixthtimestamp information from the access device, and sends the sixthtimestamp information to the fourth device, so that the fourth deviceperforms time synchronization based on the sixth timestamp information.

In an embodiment, that the fourth packet carries the second timestampinformation and the third timestamp information may be: The seconddevice uses a second protocol field included in the fourth packet tocarry the second timestamp information and the third timestampinformation. In this way, the second device can transmit the secondtimestamp information and the third timestamp information to the accessdevice.

In an embodiment, the second protocol field may be an existing protocolfield, or may be a newly added protocol field (for example, a NEW field)in an existing protocol stack framework.

In an embodiment, when the second device is a terminal device, thesecond protocol field is an SDAP field or a PDCP field. Alternatively,when the second device is a user plane network element, the secondprotocol field is a GTP field.

According to a twenty-ninth aspect, this application further provides asynchronization method.

First, a first device receives a first packet from a third device, anddetermines first timestamp information, where the first timestampinformation is a moment that is in a mobile network and at which thefirst device receives the first packet. Then, the first device sends asecond packet to an access device based on the first packet, where thesecond packet carries the first timestamp information. Subsequently,after receiving a third packet from the access device, the first devicesends the third packet to the third device, and determines secondtimestamp information, where the second timestamp information is amoment that is in the mobile network and at which the first device sendsthe third packet. Finally, the first device receives a fourth packetfrom the third device, where the fourth packet carries third timestampinformation, and the third timestamp information is a moment that is inan Ethernet network and at which the third device receives the thirdpacket sent by the first device; and the first device sends the secondtimestamp information and the third timestamp information to the accessdevice. The first device is a user plane network element and a seconddevice is a terminal device, or the first device is a terminal deviceand a second device is a user plane network element.

According to an embodiment, impact of a transmission delay between thefirst device and the second device can be avoided, so that a timeprecision requirement of an industrial factory can be met in a scenarioin which the mobile network is connected to the Ethernet network.

In an embodiment, that the second packet carries the first timestampinformation may be: The first device uses a first protocol fieldincluded in the second packet to carry the first timestamp information.In this way, the first device can successfully transmit the firsttimestamp information to the access device.

In an embodiment, the first protocol field may be an existing protocolfield, or may be a newly added protocol field (for example, a NEW field)in an existing protocol stack framework.

In an embodiment, when the first device is the user plane networkelement, the first protocol field is a GTP field. Alternatively, whenthe first device is the terminal device, the first protocol field is anSDAP field or a PDCP field.

According to a thirtieth aspect, this application further provides asynchronization method.

First, an access device receives a second packet from a first device,where the second packet carries first timestamp information, the secondpacket is sent by the first device to the access device after the firstdevice receives a first packet from a third device, and the firsttimestamp information is a moment that is in a mobile network and atwhich the first device receives the first packet. Then, the accessdevice sends a fifth packet to a second device based on the secondpacket, where the fifth packet carries the first timestamp information.Subsequently, after receiving a third packet from the second device, theaccess device sends the third packet to the first device. Finally, theaccess device receives second timestamp information and third timestampinformation from the first device, and sends the second timestampinformation and the third timestamp information to the second device,where the second timestamp information is a moment that is in the mobilenetwork and at which the first device sends the third packet to thethird device after receiving the third packet, and the third timestampinformation is a moment that is in an Ethernet network and at which thethird device receives the third packet sent by the first device. Thefirst device is a user plane network element and the second device is aterminal device, or the first device is a terminal device and the seconddevice is a user plane network element.

According to an embodiment, the access device transmits timestampinformation required for clock synchronization to the first device andthe second device, to complete clock synchronization.

In an embodiment, that the access device sends a fifth packet to asecond device based on the second packet may be: When the access devicedetects that a first protocol field included in the second packetincludes the first timestamp information, the access device encapsulatesthe first timestamp information in a second protocol field included inthe second packet to generate the fifth packet, and sends the fifthpacket to the second device. In this way, the access device cansuccessfully transmit the first timestamp information to the seconddevice.

In an embodiment, the first protocol field may be an existing protocolfield, or may be a newly added protocol field (for example, a NEW field)in an existing protocol stack framework. The second protocol field mayalternatively be an existing protocol field, or may be a newly addedprotocol field (for example, a NEW field) in an existing protocol stackframework.

In an embodiment, when the first device is the user plane networkelement, and the second device is the terminal device, the firstprotocol field is a GTP field, and the second protocol field is an SDAPfield or a PDCP field. Alternatively, when the first device is theterminal device, and the second device is the user plane networkelement, the first protocol field is an SDAP field or a PDCP field, andthe second protocol field is a GTP field.

According to a thirty-first aspect, this application further provides asynchronization method.

First, a second device receives a fifth packet from an access device,where the fifth packet carries first timestamp information, and thefirst timestamp information is a moment that is in a mobile network andat which a first device receives a first packet from a third device; andthe second device sends a sixth packet to a fourth device, anddetermines fourth timestamp information, where the fourth timestampinformation is a moment that is in the mobile network and at which thesecond device sends the sixth packet. Then, the second device receives athird packet from the fourth device, determines fifth timestampinformation, and sends the third packet to the access device, where thefifth timestamp information is a moment that is in the mobile networkand at which the second device receives the third packet. Subsequently,the second device receives second timestamp information and thirdtimestamp information from the access device, where the second timestampinformation is a moment that is in the mobile network and at which thefirst device sends the third packet to the third device after the accessdevice receives the third packet and sends the third packet to the firstdevice, and the third timestamp information is a moment that is in anEthernet network and at which the third device receives the third packetsent by the first device. Finally, the second device determines sixthtimestamp information based on the first timestamp information, thesecond timestamp information, the third timestamp information, thefourth timestamp information, and the fifth timestamp information, andsends the sixth timestamp information to the fourth device, so that thefourth device performs time synchronization based on the sixth timestampinformation. The first device is a user plane network element and thesecond device is a terminal device, or the first device is a terminaldevice and the second device is a user plane network element.

According to an embodiment, impact of a transmission delay between thefirst device and the second device can be avoided, so that a timeprecision requirement of an industrial factory can be met in a scenarioin which the mobile network is connected to the Ethernet network.

In an embodiment, that the second device determines sixth timestampinformation based on the first timestamp information, the secondtimestamp information, the third timestamp information, the fourthtimestamp information, and the fifth timestamp information may be: Thesecond device determines a round-trip transmission delay differencebetween the first device and the second device based on the firsttimestamp information, the second timestamp information, the fourthtimestamp information, and the fifth timestamp information. The seconddevice calculates a sum of the moment corresponding to the thirdtimestamp information and the round-trip transmission delay difference,to obtain the sixth timestamp information.

According to the method, the second device may accurately determine thesixth timestamp information, so that the fourth device calculates a timeoffset between the third device and the fourth device based on the sixthtimestamp information and time points of receiving and sending packetsin the Ethernet network, to perform time synchronization.

In an embodiment, after receiving the fifth packet from the accessdevice, the second device extracts the first timestamp informationcarried in a second protocol field included in the fifth packet. In thisway, the second device may subsequently determine the sixth timestampinformation by using the first timestamp information.

In an embodiment, the second protocol field may be an existing protocolfield, or may be a newly added protocol field (for example, a NEW field)in an existing protocol stack framework.

In an embodiment, when the second device is the terminal device, thesecond protocol field is an SDAP field or a PDCP field. Alternatively,when the second device is the user plane network element, the secondprotocol field is a GTP field.

According to a thirty-second aspect, this application further provides afirst device. The first device has a function of implementing behaviorof the first device in the method example in the twentieth aspect, thetwenty-third aspect, the twenty-sixth aspect, or the twenty-ninthaspect. The function may be implemented by hardware, or may beimplemented by hardware executing corresponding software. The hardwareor software includes one or more modules corresponding to the foregoingfunction.

In an embodiment, a structure of the first device includes a sendingunit, a processing unit, and a receiving unit. These units may performcorresponding functions in the method example in the twentieth aspect,the twenty-third aspect, the twenty-sixth aspect, or the twenty-ninthaspect. For details, refer to the detailed descriptions in the methodexample. Details are not described herein again.

In an embodiment, a structure of the first device includes atransceiver, a processor, and a memory. The transceiver is configuredto: receive and send data, and communicate and interact with anotherdevice in a communications system. The processor is configured tosupport the first device in performing a corresponding function in themethod in the twentieth aspect, the twenty-third aspect, thetwenty-sixth aspect, or the twenty-ninth aspect. The memory is coupledto the processor, and the memory stores a program instruction and datathat are necessary for the first device.

According to a thirty-third aspect, this application further provides anaccess device. The access device has a function of implementing behaviorof the access device in the method example in the twenty-first aspect,the twenty-fourth aspect, the twenty-seventh aspect, or the thirtiethaspect. The function may be implemented by hardware, or may beimplemented by hardware executing corresponding software. The hardwareor software includes one or more modules corresponding to the foregoingfunctions.

In an embodiment, a structure of the access device includes a sendingunit and a receiving unit. These units may perform correspondingfunctions in the method example in the twenty-first aspect, thetwenty-fourth aspect, the twenty-seventh aspect, or the thirtiethaspect. For details, refer to the detailed descriptions in the methodexample. Details are not described herein again.

In an embodiment, a structure of the access device includes atransceiver, a processor, and a memory. The transceiver is configuredto: receive and send data, and communicate and interact with anotherdevice in a communications system. The processor is configured tosupport the access device in performing a corresponding function in themethod in the twenty-first aspect, the twenty-fourth aspect, thetwenty-seventh aspect, or the thirtieth aspect. The memory is coupled tothe processor, and the memory stores a program instruction and data thatare necessary for the access device.

According to a thirty-fourth aspect, this application further provides asecond device. The second device has a function of implementing behaviorof the second device in the method example in the twenty-second aspect,the twenty-fifth aspect, the twenty-eighth aspect, or the thirty-firstaspect. The function may be implemented by hardware, or may beimplemented by hardware executing corresponding software. The hardwareor software includes one or more modules corresponding to the foregoingfunction.

In an embodiment, a structure of the second device includes a receivingunit, a processing unit, and a sending unit. These units may performcorresponding functions in the method example in the twenty-secondaspect, the twenty-fifth aspect, the twenty-eighth aspect, or thethirty-first aspect. For details, refer to the detailed descriptions inthe method example. Details are not described herein again.

In an embodiment, a structure of the second device includes atransceiver, a processor, and a memory. The transceiver is configuredto: receive and send data, and communicate and interact with anotherdevice in a communications system. The processor is configured tosupport the second device in performing a corresponding function in themethod in the twenty-second aspect, the twenty-fifth aspect, thetwenty-eighth aspect, or the thirty-first aspect. The memory is coupledto the processor, and the memory stores a program instruction and datathat are necessary for the second device.

According to a thirty-fifth aspect, this application further provides acomputer storage medium. The computer storage medium stores a computerexecutable instruction, and when the computer executable instruction isinvoked by a computer, the computer is enabled to perform any one of theforegoing methods in the twentieth aspect to the thirty-first aspect.

According to a thirty-sixth aspect, this application further provides acomputer program product including an instruction. When the computerprogram product is run on a computer, the computer is enabled to performany one of the foregoing methods in the twentieth aspect to thethirty-first aspect.

According to a thirty-seventh aspect, this application further providesa chip. The chip is connected to a memory, and is configured to: readand execute a program instruction stored in the memory, to implement anyone of the foregoing methods in the twentieth aspect to the thirty-firstaspect.

BRIEF DESCRIPTION OF DRAWINGS

FIG. 1 is an architectural diagram of a communications system accordingto an embodiment of the application;

FIG. 2 is a schematic working diagram of a communications systemaccording to an embodiment of the application;

FIG. 3 is a flowchart of a synchronization method according to anembodiment of the application;

FIG. 4 is a schematic diagram of packet receiving and sending in asynchronization process according to an embodiment of the application;

FIG. 5 is a schematic diagram of a protocol stack framework;

FIG. 6 is a schematic diagram of another protocol stack frameworkaccording to an embodiment of the application;

FIG. 7 is a flowchart of another synchronization method according to anembodiment of the application;

FIG. 8 is a flowchart of another synchronization method according to anembodiment of the application;

FIG. 9 is another schematic diagram of packet receiving and sending in asynchronization process according to an embodiment of the application;

FIG. 10 is a flowchart of another synchronization method according to anembodiment of the application;

FIG. 11 is a schematic structural diagram of a first device according toan embodiment of the application;

FIG. 12 is a schematic structural diagram of an access device accordingto an embodiment of the application;

FIG. 13 is a schematic structural diagram of a second device accordingto an embodiment of the application;

FIG. 14 is a schematic structural diagram of another first deviceaccording to an embodiment of the application;

FIG. 15 is a schematic structural diagram of another first deviceaccording to an embodiment of the application;

FIG. 16 is a schematic structural diagram of another second deviceaccording to an embodiment of the application;

FIG. 17 is a schematic structural diagram of another first deviceaccording to an embodiment of the application;

FIG. 18 is a structural diagram of a first device according to anembodiment of the application;

FIG. 19 is a structural diagram of an access device according to anembodiment of the application;

FIG. 20 is a structural diagram of a second device according to anembodiment of the application;

FIG. 21 is a flowchart of another synchronization method according to anembodiment of the application;

FIG. 22 is another schematic diagram of packet receiving and sending ina synchronization process according to an embodiment of the application;

FIG. 23 is a schematic working diagram of another communications systemaccording to an embodiment of the application;

FIG. 24 is a flowchart of another synchronization method according to anembodiment of the application;

FIG. 25 is another schematic diagram of packet receiving and sending ina synchronization process according to an embodiment of the application;

FIG. 26 is a flowchart of another synchronization method according to anembodiment of the application;

FIG. 27 is another schematic diagram of packet receiving and sending ina synchronization process according to an embodiment of the application;

FIG. 28 is a flowchart of another synchronization method according to anembodiment of the application; and

FIG. 29 is another schematic diagram of packet receiving and sending ina synchronization process according to an embodiment of the application.

DESCRIPTION OF EMBODIMENTS

The following further describes in detail this application withreference to the accompanying drawings.

The embodiments of this application provide a synchronization method andan apparatus, to meet a time precision requirement of an industrialfactory in a scenario in which a mobile network is connected to anEthernet network (for example, a TSN). The method and the apparatus inthis application are based on a same inventive concept. The method andthe apparatus have similar problem resolving principles. Therefore, forimplementation of the apparatus and the method, mutual reference may bemade to each other. Details of repeated parts are not described.

The following explains some terms in this application to facilitateunderstanding by one of ordinary skilled in the art.

(1) Terminal device: The terminal device is also referred to as userequipment (user equipment, UE), a mobile station (MS), a mobile terminal(MT), or the like, and is a device that provides voice and/or dataconnectivity for a user. For example, in an industrial factory scenario,the terminal device may be a sensor, a servo motor, a mobile robot, orthe like.

(2) User plane network element: The user plane network element may beconfigured to forward user plane data of the terminal device. The userplane network element is mainly used to route and forward a data packet,and serves as a mobility anchor. In addition, the user plane networkelement may further serve as an uplink classifier to support routing ofa service flow to a data network, or serve as a branch point to supporta multi-homed packet data unit (PDU) session, or the like. For example,the user plane network element may be a user plane function (UPF)network element.

(3) First device and second device: The first device and the seconddevice are respectively a master clock node and a node that needs toperform clock synchronization. In a communication process, a clock ofthe second device needs to be synchronized with a clock of the firstdevice. In an Ethernet network, the first device and the second deviceare adjacent devices. In a mobile network, there is at least one hop ofanother device, for example, an access device, between the first deviceand the second device. For example, the first device is the user planenetwork element and the second device is the terminal device, or thefirst device is the terminal device and the second device is the userplane network element.

(4) Access device: The access device provides a wireless access servicefor the terminal device. The access device is a node in a radio accessnetwork, and may also be referred to as a base station, or may also bereferred to as a radio access network (RAN) node (or device). Currently,for example, the access device is a gNB, a transmission reception point(TRP), an evolved NodeB (eNB), a radio network controller (RNC), a NodeB(NB), a base station controller (BSC), a base transceiver station (BTS),a home base station (for example, a home evolved NodeB or a home NodeB,HNB), a baseband unit (BBU), or a wireless fidelity (Wi-Fi) access point(AP).

(5) Words such as “first” and “second”: In the descriptions of thisapplication, the words such as “first” and “second” are merely used fordifferentiation and description, and shall not be understood as anindication or implication of relative importance or an indication orimplication of an order.

To describe the technical solutions in the embodiments of thisapplication more clearly, the following describes, in detail withreference to the accompanying drawings, the synchronization method andthe apparatus that are provided in the embodiments of this application.

FIG. 1 shows an architecture of a possible communications system towhich a synchronization method is applicable according to an embodimentof this application. The communications system includes two parts: anEthernet network and a mobile network. In the communications system, theEthernet network is an Ethernet network in an industrial network, andthe mobile network is applied to the industrial network and is connectedto the Ethernet network. In FIG. 1, the Ethernet network is shown as aTSN network, and the mobile network is shown as a 5th generation (5G)mobile communications technology network.

The TSN network includes a programmable logic controller (PLC), anothercontrol device, a terminal device, a user plane network element, and thelike. The PLC may be a master clock device in the TSN network. Forexample, as shown in FIG. 1, a servo motor 1 is the another controldevice, and a sensor 1 is the terminal device in the TSN network.

The 5G network may include a user plane network element, an accessdevice, a terminal device, and the like. The user plane network elementis shown as a UPF in FIG. 1. The access device is shown as a radioaccess network (RAN) node (or device). A sensor 2, a servo motor 2, anda mobile robot are all examples of terminal devices.

It should be noted that the TSN network shown in FIG. 1 is merely usedas an example of the Ethernet network, and the 5G network is merely usedas an example of the mobile network. The TSN network and the 5G networkcannot be used as a limitation on the communications system in thisapplication. The Ethernet network may have a plurality of otherexamples, and the mobile network may have a plurality of other examples,which are not listed one by one herein.

FIG. 2 is a schematic working diagram of a communications system towhich a synchronization method is applicable according to an embodimentof this application.

A packet in FIG. 2 may be an Ethernet packet, an Ethernet data packet,or the like, and the packet may be used as a data packet in a PDUsession process in a mobile network for transmission.

A master clock device in an Ethernet network is a PLC, and a masterclock in the Ethernet network is determined by the PLC. FIG. 2 shows amaster clock T1 in an Ethernet network synchronization domain. In theEthernet network synchronization domain, UE and a UPF are considered astwo adjacent nodes. During clock synchronization, when the UPF is usedas a master clock node, the UE needs to perform clock synchronizationbased on master clock information of the UPF.

In a mobile network synchronization domain, a master clock device may bea building integrated timing supply (BITS) system, a time server, aglobal positioning system (GPS), BeiDou, or the like. A master clock inthe mobile network is determined by the master clock device. FIG. 2shows a master clock T2 in the mobile network synchronization domain.Correspondingly, in the Ethernet network, there is another multi-hopdevice, for example, a RAN, between the UE and the UPF that are adjacentnodes. However, currently, clock synchronization in the mobile networkis implemented. Therefore, clock synchronization in the Ethernet networkcan be performed based on clock synchronization in the mobile network.

It should be noted that FIG. 2 shows only a case in which the UPF isused as the master clock node, and the UE needs to perform clocksynchronization. In an embodiment, in FIG. 2, locations of the UE andthe UPF may be exchanged. For example, the UE may be used as the masterclock node, and the UPF needs to perform clock synchronization.

It should be noted that the UE in FIG. 2 is merely used as an example ofa terminal device, or the UE may be replaced with another terminaldevice (for example, the mobile robot or the sensor 2 in FIG. 1). TheUPF is merely used as an example of a user plane network element, or theUPF may be replaced with another user plane network element. This is notlimited in this application.

An embodiment of this application provides a synchronization method,which is applicable to the communications systems shown in FIG. 1 andFIG. 2. For example, in FIG. 3, a first device is the UPF and a seconddevice is the UE, or the first device is the UE and the second device isthe UPF. Referring to FIG. 3, a procedure of the method includes thefollowing operations.

Operation 301: The first device sends a first packet to an accessdevice, where the first packet carries first timestamp information, anddetermines second timestamp information, where the first timestampinformation is a moment that is in an Ethernet network and at which thefirst device sends the first packet, and the second timestampinformation is a moment that is in a mobile network and at which thefirst device sends the first packet.

In an embodiment, before the first device sends the first packet to theaccess device, the first device receives a data packet from the Ethernetnetwork (for example, a TSN). If the first device identifies that format(type) information of the data packet is 0x88f7, the first devicedetermines that the data packet is an 802.1AS synchronization datapacket. Then, the first device sends the first packet to the accessdevice, and in this case, initiates a clock synchronization procedure.

For example, FIG. 4 is a schematic diagram of packet receiving andsending in a process of performing synchronization between the firstdevice and the second device. In FIG. 4, a solid line indicates atransmission status of a packet in the Ethernet network, and a dashedline indicates a transmission status of a packet in the mobile network.It should be understood that in FIG. 4, a solid line and a dashed linethat are parallel in a same direction indicate transmission of a samepacket.

For example, in operation 301, the moment corresponding to the firsttimestamp information is denoted as t1 in FIG. 4, and the secondtimestamp information is denoted as t1′ in FIG. 4.

In an embodiment, after determining the second timestamp information,the first device locally records the second timestamp information, sothat the first device subsequently calculates a round-trip transmissiondelay difference between the first device and the second device.

The first device is a user plane network element and the second deviceis a terminal device, or the first device is a terminal device and thesecond device is a user plane network element. In other words, either ofthe user plane network element and the terminal device may be a masterclock node, and the other needs to perform clock synchronization.

Operation 302: The access device sends a third packet to the seconddevice based on the first packet, where the third packet carries thefirst timestamp information.

When the access device performs operation 302, the method may be: Theaccess device forwards the first packet to the second device. In thiscase, the third packet is the first packet.

Operation 303: The second device determines third timestamp informationand eighth timestamp information, where the third timestamp informationis a moment that is in the mobile network and at which the second devicereceives the third packet, and the eighth timestamp information is amoment that is in the Ethernet network and at which the second devicereceives the third packet.

For example, in FIG. 4, the moment corresponding to the third timestampinformation is denoted as t2′, and the eighth timestamp information isdenoted as t2.

Operation 304: The second device sends a fourth packet to the accessdevice, where the fourth packet carries the third timestamp informationand fourth timestamp information, and the fourth timestamp informationis a moment that is in the mobile network and at which the second devicesends the fourth packet to the access device.

For example, in FIG. 4, the moment corresponding to the fourth timestampinformation is denoted as t3′.

In an embodiment, the fourth packet may further carry a flag, and theflag is used to indicate that the fourth packet carries timestampinformation indicating a moment in the mobile network.

In an embodiment, a implementation method in which the fourth packetcarries the third timestamp information and the fourth timestampinformation may be: The second device uses a second protocol fieldincluded in the fourth packet to carry the third timestamp informationand the fourth timestamp information. For example, the second protocolfield may be an existing protocol field in the fourth packet in acurrent protocol stack framework. Alternatively, the second protocolfield may be a protocol field newly added to the fourth packet in acurrent protocol stack framework. For example, when the fourth packetfurther carries a flag, the flag may also be carried in the secondprotocol field.

For example, FIG. 5 is a schematic diagram of an existing protocol stackframework. The protocol stack framework indicates examples (namely,examples of packet formats) of fields in a packet at different locations(namely, different devices).

The second protocol field is described in detail based on the example inFIG. 5.

In an example implementation, when the second device is the terminaldevice and the first device is the user plane network element, thesecond protocol field may have the following two cases:

Case a1: The second protocol field may be a service data protocol (SDAP)field or a packet data convergence protocol (PDCP) field. In this case,the second device encapsulates the third timestamp information and thefourth timestamp information in an SDAP field or a PDCP field in apacket protocol field corresponding to the terminal device shown in FIG.5, and then sends the fourth packet obtained after the encapsulation tothe access device.

Certainly, in addition to the SDAP field or the PDCP field, the secondprotocol field may be any other field in the packet protocol fieldcorresponding to the terminal device shown in FIG. 5. This is notlimited in this application. When the second protocol field is anotherprotocol field, details are not described herein again.

Case a2: The second protocol field may be a newly added protocol fieldin the protocol stack shown in FIG. 5, and may be denoted as a newprotocol (new protocol) field (briefly referred to as a NEW fieldbelow). For example, in this case, the second device adds a new protocolfield NEW field to the packet protocol field corresponding to theterminal device shown in FIG. 5, for example, as shown in a packetprotocol field corresponding to the terminal device in a protocol stackarchitecture shown in FIG. 6, then encapsulates the third timestampinformation and the fourth timestamp information in the NEW field, andsends the fourth packet obtained after the encapsulation to the accessdevice.

It should be noted that the NEW field is merely used as an example. Forexample, the NEW field may alternatively have any other names with asame function. This is not limited in this application.

In another example implementation, when the second device is the userplane network element and the first device is the terminal device, thesecond protocol field may have the following two cases:

Case b1: The second protocol field is a general packet radio servicetunneling protocol (GTP) field. In this case, the second deviceencapsulates the third timestamp information and the fourth timestampinformation in a GTP field in a packet protocol field corresponding tothe user plane network element shown in FIG. 5, and then sends thefourth packet obtained after the encapsulation to the access device.

Certainly, in addition to the GTP field, the second protocol field maybe any other field in the packet protocol field corresponding to theuser plane network element shown in FIG. 5. This is not limited in thisapplication. When the second protocol field is another field, detailsare not described herein again.

Case b2: The second protocol field may be a newly added protocol fieldin the protocol stack shown in FIG. 5, and may be denoted as a newprotocol field (briefly referred to as a NEW field below). For example,in this case, the second device adds a new protocol field NEW field tothe packet protocol field corresponding to the user plane networkelement shown in FIG. 5, for example, as shown in a packet protocolfield corresponding to the user plane network element in a protocolstack architecture shown in FIG. 6, then encapsulates the thirdtimestamp information and the fourth timestamp information in the NEWfield, and sends the fourth packet obtained after the encapsulation tothe access device.

It should be noted that the NEW field is merely used as an example. Forexample, the NEW field may alternatively have any other names with asame function. This is not limited in this application.

Operation 305: The second device determines ninth timestamp information,where the ninth timestamp information is a moment that is in theEthernet network and at which the second device sends the fourth packetto the access device.

For example, in FIG. 4, the moment corresponding to the ninth timestampinformation is denoted as t3.

Operation 306: The access device sends a second packet to the firstdevice, where the second packet carries the third timestamp informationand the fourth timestamp information.

For example, a method in which the access device sends the second packetto the first device may be: When detecting that a second protocol fieldincluded in the fourth packet carries the third timestamp informationand the fourth timestamp information, the access device encapsulates thethird timestamp information and the fourth timestamp information in afirst protocol field included in the fourth packet to generate thesecond packet, and sends the second packet to the first device.

For example, for a case of the second protocol field, refer to therelated descriptions of the second protocol field in operation 304.Similarly, the first protocol field may also be an existing protocolfield, or may be a newly added field in an existing protocol stackframework. There may be a plurality of actual cases of the firstprotocol field based on actual cases of the first device and the seconddevice and different actual cases of the second protocol field.

In a possible implementation, when the second protocol field meets Casea1 in operation 304, the first protocol field may have the following twocases:

Case c1: The first protocol field may be a GTP field. In this case, whenthe access device detects that the third timestamp information and thefourth timestamp information are encapsulated in the SDAP field or thePDCP field in the received fourth packet, the access device extracts thethird timestamp information and the fourth timestamp information fromthe SDAP field or the PDCP field, and then encapsulates the thirdtimestamp information and the fourth timestamp information in a GTPfield in a packet protocol field corresponding to the access deviceshown in FIG. 5, to generate the second packet. In this case, the GTPfield in the second packet includes the third timestamp information andthe fourth timestamp information.

Certainly, in addition to the GTP field, the first protocol field may beany other field in the packet protocol field corresponding to the accessdevice shown in FIG. 5. This is not limited in this application. Whenthe first protocol field is another protocol field, details are notdescribed herein again.

Case c2: The first protocol field may be a newly added protocol field inthe protocol stack shown in FIG. 5, and may be denoted as a new protocolfield (briefly referred to as a NEW field below). For example, in thiscase, when the access device detects that the third timestampinformation and the fourth timestamp information are encapsulated in theSDAP field or the PDCP field in the received fourth packet, the accessdevice extracts the third timestamp information and the fourth timestampinformation from the SDAP field or the PDCP field. Then, the accessdevice adds a new protocol field NEW field to the packet protocol fieldcorresponding to the access device shown in FIG. 5, for example, asshown in a packet protocol field corresponding to the access device in aprotocol stack architecture shown in FIG. 6, and then encapsulates thethird timestamp information and the fourth timestamp information in theNEW field to obtain the second packet. In this case, the NEW field inthe second packet includes the third timestamp information and thefourth timestamp information.

In another possible implementation, when the second protocol field meetsCase a2 in operation 304, the first protocol field may have thefollowing two cases:

Case d1: The first protocol field may be a GTP field. In this case, whenthe access device detects that the third timestamp information and thefourth timestamp information are encapsulated in the NEW field in thereceived fourth packet, the access device extracts the third timestampinformation and the fourth timestamp information from the NEW field, andthen encapsulates the third timestamp information and the fourthtimestamp information in a GTP field in a packet protocol fieldcorresponding to the access device shown in FIG. 5, to generate thesecond packet. In this case, the GTP field in the second packet includesthe third timestamp information and the fourth timestamp information.

Certainly, in addition to the GTP field, the first protocol field may beany other field in the packet protocol field corresponding to the accessdevice shown in FIG. 5. This is not limited in this application. Whenthe first protocol field is another protocol field, details are notdescribed herein again.

Case d2: The first protocol field may be a newly added protocol field inthe protocol stack shown in FIG. 5, and may be denoted as a new protocolfield (briefly referred to as a NEW field below). For example, in thiscase, when the access device detects that the third timestampinformation and the fourth timestamp information are encapsulated in theNEW field in the received fourth packet, the access device extracts thethird timestamp information and the fourth timestamp information fromthe NEW field. Then, the access device adds a new protocol field NEWfield to the packet protocol field corresponding to the access deviceshown in FIG. 5, for example, as shown in a packet protocol fieldcorresponding to the access device in a protocol stack architectureshown in FIG. 6, and then encapsulates the third timestamp informationand the fourth timestamp information in the NEW field to obtain thesecond packet. In this case, the NEW field in the second packet includesthe third timestamp information and the fourth timestamp information.

In another possible implementation, when the second protocol field meetsCase b1 in operation 304, the first protocol field may have thefollowing two cases:

Case e1: The first protocol field may be an SDAP field or a PDCP field.In this case, when the access device detects that the third timestampinformation and the fourth timestamp information are encapsulated in theGTP field in the received fourth packet, the access device extracts thethird timestamp information and the fourth timestamp information fromthe GTP field, and then encapsulates the third timestamp information andthe fourth timestamp information in an SDAP field or a PDCP field in apacket protocol field corresponding to the access device shown in FIG.5, to generate the second packet. In this case, the SDAP field or thePDCP field in the second packet includes the third timestamp informationand the fourth timestamp information.

Certainly, in addition to the SDAP field or the PDCP field, the firstprotocol field may be any other field in the packet protocol fieldcorresponding to the access device shown in FIG. 5. This is not limitedin this application. When the first protocol field is another protocolfield, details are not described herein again.

Case e2: The first protocol field may be a newly added protocol field inthe protocol stack shown in FIG. 5, and may be denoted as a new protocolfield (briefly referred to as a NEW field below). For example, in thiscase, when the access device detects that the third timestampinformation and the fourth timestamp information are encapsulated in theGTP field in the received fourth packet, the access device extracts thethird timestamp information and the fourth timestamp information fromthe GTP field. Then, the access device adds a new protocol field NEWfield to the packet protocol field corresponding to the access deviceshown in FIG. 5, for example, as shown in a packet protocol fieldcorresponding to the access device in a protocol stack architectureshown in FIG. 6, and then encapsulates the third timestamp informationand the fourth timestamp information in the NEW field to obtain thesecond packet. In this case, the NEW field in the second packet includesthe third timestamp information and the fourth timestamp information.

In another possible implementation, when the second protocol field meetsCase b2 in operation 304, the first protocol field may have thefollowing two cases:

Case f1: The first protocol field may be an SDAP field or a PDCP field.In this case, when the access device detects that the third timestampinformation and the fourth timestamp information are encapsulated in theNEW field in the received fourth packet, the access device extracts thethird timestamp information and the fourth timestamp information fromthe NEW field, and then encapsulates the third timestamp information andthe fourth timestamp information in an SDAP field or a PDCP field in apacket protocol field corresponding to the access device shown in FIG.5, to generate the second packet. In this case, the SDAP field or thePDCP field in the second packet includes the third timestamp informationand the fourth timestamp information.

Certainly, in addition to the SDAP field or the PDCP field, the firstprotocol field may be any other field in the packet protocol fieldcorresponding to the access device shown in FIG. 5. This is not limitedin this application. When the first protocol field is another protocolfield, details are not described herein again.

Case f2: Same as Case d2, reference may be made to each other. Detailsare not described herein again.

For example, when the fourth packet carries the flag, in Cases c1, c2,d1, d2, e1, e2, f1 and f2, the access device may perform the foregoingprocess when detecting that the second protocol field in the fourthpacket includes the flag. For example, the access device extracts theflag from the second protocol field, and also encapsulates the flag inthe first protocol field.

For example, after the first device receives the second packet, thefirst device extracts the third timestamp information and the fourthtimestamp information that are carried in the first protocol fieldincluded in the second packet. For example, based on the various casesof the first protocol field described above, there may be the followingthree cases:

Case g1: The first device extracts the third timestamp information andthe fourth timestamp information from the GTP field. In this case, thefirst device is the user plane network element, and a packet protocolfield corresponding to the first device is a field corresponding to theuser plane network element shown in FIG. 5.

Case g2: The first device extracts the third timestamp information andthe fourth timestamp information from the SDAP field or the PDCP field.In this case, the first device is the terminal device, and a packetprotocol field corresponding to the first device is a fieldcorresponding to the terminal device shown in FIG. 5.

Case g3: The first device extracts the third timestamp information andthe fourth timestamp information from the NEW field. In this case, thefirst device is the terminal device or the user plane network element.When the first device is the terminal device, a packet protocol fieldcorresponding to the first device is a field corresponding to theterminal device shown in FIG. 6. When the first device is the user planenetwork element, a packet protocol field corresponding to the firstdevice is a field corresponding to the user plane network element shownin FIG. 6.

In an embodiment, when the access device detects that the secondprotocol field is the NEW field, or when the third timestamp informationand the fourth timestamp information are encapsulated in the NEW field,the access device may not process the fourth packet, but directlyforwards the fourth packet to the first device. In this case, the fourthpacket is the second packet. In this way, after the first devicereceives the second packet, the first device may directly extract thethird timestamp information and the fourth timestamp information fromthe second protocol field (namely, the NEW field). In this case, thepacket protocol field corresponding to the first device is the fieldcorresponding to the user plane network element or the terminal deviceshown in FIG. 6. In this process, a packet protocol field correspondingto the access device is a field corresponding to the access device shownin FIG. 5.

Operation 307: The first device determines fifth timestamp informationand sixth timestamp information, where the fifth timestamp informationis a moment that is in the Ethernet network and at which the firstdevice receives the second packet, and the sixth timestamp informationis a moment that is in the mobile network and at which the first devicereceives the second packet.

For example, in FIG. 4, the moment corresponding to the fifth timestampinformation is denoted as t4, and the moment corresponding to the sixthtimestamp information is denoted as t4′.

Operation 308: The first device determines seventh timestamp informationbased on the second timestamp information, the third timestampinformation, the fourth timestamp information, the fifth timestampinformation, and the sixth timestamp information.

In an embodiment, when the first device performs operation 308, a methodmay be: The first device determines a round-trip transmission delaydifference between the first device and the second device based on thesecond timestamp information (t1′), the third timestamp information(t2′), the fourth timestamp information (t3′), and the sixth timestampinformation (t4′). The first device calculates a sum of the moment (t4)corresponding to the fifth timestamp information and the round-triptransmission delay difference, to obtain the seventh timestampinformation.

For example, the round-trip transmission delay difference between thefirst device and the second device may be calculated through clocksynchronization between the first device and the second device that isimplemented in the mobile network. For example, the round-triptransmission delay difference may be obtained through calculation byusing Formula 1 and Formula 2:t2−t1′=delay1+offset1  Formula 1; andt4−t3′=delay2−offset1  Formula 2.

In the foregoing formulas, offset 1 is a time offset between the firstdevice and the second device in the mobile network, delay 1 is atransmission delay from the first device to the second device, and delay2 is a transmission delay from the second device to the first device.

Due to clock synchronization in the mobile network, a value of offset 1is 0. Therefore, the round-trip transmission delay difference may beobtained by using Formula 1 and Formula 2, that is, delay 1−delay2=t2′−t1′−t4′+t3′.

Further, a moment corresponding to the seventh timestamp information ist4+t2′−t1′−t4′+t3′.

Operation 309: The first device sends the seventh timestamp informationto the access device.

For example, in the prior art, the first device sends the fifthtimestamp information to the access device, so that the access devicesends the fifth timestamp information to the second device. In thisapplication, the first device sends the seventh timestamp information tothe second device by using an existing method for sending the fifthtimestamp information. It may also be understood that the seventhtimestamp information is sent to the second device in place of the fifthtimestamp information. In this way, when receiving the seventh timestampinformation, the second device uses the seventh timestamp information asthe fifth timestamp information in the prior art for processing.

Operation 310: The access device sends the seventh timestamp informationto the second device.

Operation 311: The second device determines a time offset between thefirst device and the second device based on the first timestampinformation (t1), the eighth timestamp information (t2), the ninthtimestamp information (t3), and the seventh timestamp information(t4+t2′−t1′−t4′+t3′), and performs time synchronization based on thetime offset.

In an embodiment, as described in operation 309, the second device maydetermine, based on the seventh timestamp information, the moment thatis in the Ethernet network, at which the first device receives thesecond packet, and that is considered by the second device, and use theseventh timestamp information as the fifth timestamp information.

For example, a time offset, namely, offset 2, between the first deviceand the second device may satisfy Formula 3:

$\begin{matrix}{{{offset}\; 2} = {\frac{{t\; 2} - {t\; 1} - \left( {{t\; 4} + {t\; 2^{\prime}} - {t\; 1^{\prime}} - {t\; 4^{\prime}} + {t\; 3^{\prime}}} \right) + {t\; 3}}{2}.}} & {{Formula}\mspace{14mu} 3}\end{matrix}$

It should be noted that all packets in an embodiment are 802.1ASprotocol packets.

In an embodiment, when the timestamp information corresponding to themoment in the mobile network is carried in any one of the GTP field, theSDAP field, the NEW field, and the like in the packet, N bytes may bereserved in a corresponding protocol field to store the timestampinformation. For example, N is a positive integer, for example, N is 10.For example, when the protocol field carries both the timestampinformation and the flag, M bytes are reserved in the protocol field tostore the flag, where M is a positive integer. For example, M is 1.

According to the synchronization method provided in an embodiment ofthis application, the first device determines the seventh timestampinformation by using timestamp information of receiving and sendingpackets in the mobile network, so that the second device calculates atime offset between the first device and the second device based on theseventh timestamp information and time points of receiving and sendingpackets in the Ethernet network, to perform time synchronization. In themethod, impact of a transmission delay between the first device and thesecond device can be avoided, so that a time precision requirement of anindustrial factory can be met in a scenario in which the mobile networkis connected to the Ethernet network.

An embodiment of this application further provides anothersynchronization method, which is applicable to the communicationssystems shown in FIG. 1 and FIG. 2. For example, in FIG. 7, a firstdevice is the UPF and a second device is the UE, or the first device isthe UE and the second device is the UPF. Referring to FIG. 7, aprocedure of the method may include the following operations.

Operation 701: The first device sends a first packet to an accessdevice, where the first packet carries first timestamp information andsecond timestamp information, the first timestamp information is amoment that is in an Ethernet network and at which the first devicesends the first packet, and the second timestamp information is a momentthat is in a mobile network and at which the first device sends thefirst packet.

A trigger condition for initiating a clock synchronization procedure bythe first device is the same as the principle described in operation 301in the embodiment shown in FIG. 3. For details, reference may be made toeach other. The details are not described herein again.

For the schematic diagram of packet receiving and sending in the processof performing synchronization between the first device and the seconddevice that is shown in FIG. 4, also refer to an embodiment. Forexample, the moment corresponding to the first timestamp information inoperation 401 is denoted as t1 in FIG. 4, and the second timestampinformation is denoted as t1′ in FIG. 4.

The first device is a user plane network element and the second deviceis a terminal device, or the first device is a terminal device and thesecond device is a user plane network element. In other words, either ofthe user plane network element and the terminal device may be a masterclock node, and the other needs to perform clock synchronization.

For example, the first packet may further carry a flag, and the flag isused to indicate that the first packet carries timestamp informationindicating a moment in the mobile network.

In an embodiment, a implementation method in which the first packetcarries the second timestamp information may be: The first device uses afirst protocol field included in the first packet to carry the secondtimestamp information. For example, the first protocol field may be anexisting protocol field in the first packet in a current protocol stackframework. Alternatively, the first protocol field may be a protocolfield newly added to the first packet in a current protocol stackframework. For example, when the first packet further carries a flag,the flag may also be carried in the first protocol field.

Similarly, the first protocol field is described in detail still basedon the example shown in FIG. 5.

In an example implementation, when the first device is the terminaldevice and the second device is the user plane network element, thefirst protocol field may have the following two cases:

Case h1: The first protocol field may be an SDAP field or a PDCP field.In this case, the first device encapsulates the second timestampinformation in an SDAP field or a PDCP field in a packet protocol fieldcorresponding to the terminal device shown in FIG. 5, and then sends thefirst packet obtained after the encapsulation to the access device.

Certainly, in addition to the SDAP field or the PDCP field, the firstprotocol field may be any other field in the packet protocol fieldcorresponding to the terminal device shown in FIG. 5. This is notlimited in this application. When the first protocol field is anotherprotocol field, details are not described herein again.

Case h2: The first protocol field may be a newly added protocol field inthe protocol stack shown in FIG. 5, and may be denoted as a new protocolfield (briefly referred to as a NEW field below). For example, in thiscase, the first device adds a new protocol field NEW field to the packetprotocol field corresponding to the terminal device shown in FIG. 5, forexample, as shown in a packet protocol field corresponding to theterminal device in a protocol stack architecture shown in FIG. 6, thenencapsulates the second timestamp information in the NEW field, andsends the first packet obtained after the encapsulation to the accessdevice.

It should be noted that the NEW field is merely used as an example. Forexample, the NEW field may alternatively have any other names with asame function. This is not limited in this application.

In another example implementation, when the first device is the userplane network element and the second device is the terminal device, thefirst protocol field may have the following two cases:

Case i1: The first protocol field is a GTP field. In this case, thefirst device encapsulates the second timestamp information in a GTPfield in a packet protocol field corresponding to the user plane networkelement shown in FIG. 5, and then sends the first packet obtained afterthe encapsulation to the access device.

Certainly, in addition to the GTP field, the first protocol field may beany other field in the packet protocol field corresponding to the userplane network element shown in FIG. 5. This is not limited in thisapplication. When the first protocol field is another field, details arenot described herein again.

Case i2: The first protocol field may be a newly added protocol field inthe protocol stack shown in FIG. 5, and may be denoted as a new protocolfield (briefly referred to as a NEW field below). For example, in thiscase, the first device adds a new protocol field NEW field to the packetprotocol field corresponding to the user plane network element shown inFIG. 5, for example, as shown in a packet protocol field correspondingto the user plane network element in a protocol stack architecture shownin FIG. 6, then encapsulates the second timestamp information in the NEWfield, and sends the first packet obtained after the encapsulation tothe access device.

It should be noted that the NEW field is merely used as an example. Forexample, the NEW field may alternatively have any other names with asame function. This is not limited in this application.

Operation 702: The access device sends a third packet to the seconddevice based on the first packet, where the third packet carries thefirst timestamp information and the second timestamp information.

In an embodiment, a method in which the access device sends the thirdpacket to the second device based on the first packet may be: When theaccess device detects that a first protocol field included in the firstpacket includes the second timestamp information, the access deviceencapsulates the second timestamp information in a second protocol fieldincluded in the first packet to generate the third packet, and sends thethird packet to the second device. In this case, a second protocol fieldin the third packet carries the second timestamp information.

For example, for a case of the first protocol field, refer to therelated descriptions of the first protocol field in operation 701.Similarly, the second protocol field may also be an existing protocolfield, or may be a newly added field in an existing protocol stackframework. There may be a plurality of actual cases of the secondprotocol field based on actual cases of the first device and the seconddevice and different actual cases of the first protocol field.

In an embodiment, when the first protocol field meets Case h1 inoperation 701, the second protocol field may have the following twocases:

Case j1: The second protocol field may be a GTP field. In this case,when the access device detects that the second timestamp information isencapsulated in the SDAP field or the PDCP field in the received firstpacket, the access device extracts the second timestamp information fromthe SDAP field or the PDCP field, and then encapsulates the secondtimestamp information in a GTP field in a packet protocol fieldcorresponding to the access device shown in FIG. 5, to generate thethird packet. In this case, the GTP field in the third packet includesthe second timestamp information.

Certainly, in addition to the GTP field, the second protocol field maybe any other field in the packet protocol field corresponding to theaccess device shown in FIG. 5. This is not limited in this application.When the second protocol field is another protocol field, details arenot described herein again.

Case j2: The second protocol field may be a newly added protocol fieldin the protocol stack shown in FIG. 5, and may be denoted as a newprotocol field (briefly referred to as a NEW field below). For example,in this case, when the access device detects that the second timestampinformation is encapsulated in the SDAP field or the PDCP field in thereceived first packet, the access device extracts the second timestampinformation from the SDAP field or the PDCP field. Then, the accessdevice adds a new protocol field NEW field to the packet protocol fieldcorresponding to the access device shown in FIG. 5, for example, asshown in a packet protocol field corresponding to the access device in aprotocol stack architecture shown in FIG. 6, and then encapsulates thesecond timestamp information in the NEW field to obtain the thirdpacket. In this case, the NEW field in the third packet includes thesecond timestamp information.

In another embodiment, when the first protocol field meets Case h2 inoperation 701, the second protocol field may have the following twocases:

Case k1: The second protocol field may be a GTP field. In this case,when the access device detects that the second timestamp information isencapsulated in the NEW field in the received first packet, the accessdevice extracts the second timestamp information from the NEW field, andthen encapsulates the second timestamp information in a GTP field in apacket protocol field corresponding to the access device shown in FIG.5, to generate the third packet. In this case, the GTP field in thethird packet includes the second timestamp information.

Certainly, in addition to the GTP field, the second protocol field maybe any other field in the packet protocol field corresponding to theaccess device shown in FIG. 5. This is not limited in this application.When the second protocol field is another protocol field, details arenot described herein again.

Case k2: The second protocol field may be a newly added protocol fieldin the protocol stack shown in FIG. 5, and may be denoted as a newprotocol field (briefly referred to as a NEW field below). For example,in this case, when the access device detects that the second timestampinformation is encapsulated in the NEW field in the received firstpacket, the access device extracts the second timestamp information fromthe NEW field. Then, the access device adds a new protocol field NEWfield to the packet protocol field corresponding to the access deviceshown in FIG. 5, for example, as shown in a packet protocol fieldcorresponding to the access device in a protocol stack architectureshown in FIG. 6, and then encapsulates the second timestamp informationin the NEW field to obtain the third packet. In this case, the NEW fieldin the third packet includes the second timestamp information.

In another embodiment, when the first protocol field meets Case i1 inoperation 701, the second protocol field may have the following twocases:

Case l1: The second protocol field may be an SDAP field or a PDCP field.In this case, when the access device detects that the second timestampinformation is encapsulated in the GTP field in the received firstpacket, the access device extracts the second timestamp information fromthe GTP field, and then encapsulates the second timestamp information inan SDAP field or a PDCP field in a packet protocol field correspondingto the access device shown in FIG. 5, to generate the third packet. Inthis case, the SDAP field or the PDCP field in the third packet includesthe second timestamp information.

Certainly, in addition to the SDAP field or the PDCP field, the secondprotocol field may be any other field in the packet protocol fieldcorresponding to the access device shown in FIG. 5. This is not limitedin this application. When the second protocol field is another protocolfield, details are not described herein again.

Case l2: The second protocol field may be a newly added protocol fieldin the protocol stack shown in FIG. 5, and may be denoted as a newprotocol field (briefly referred to as a NEW field below). For example,in this case, when the access device detects that the second timestampinformation is encapsulated in the GTP field in the received firstpacket, the access device extracts the second timestamp information fromthe GTP field. Then, the access device adds a new protocol field NEWfield to the packet protocol field corresponding to the access deviceshown in FIG. 5, for example, as shown in a packet protocol fieldcorresponding to the access device in a protocol stack architectureshown in FIG. 6, and then encapsulates the second timestamp informationin the NEW field to obtain the third packet. In this case, the NEW fieldin the third packet includes the second timestamp information.

In another embodiment, when the second protocol field meets Case i2 inoperation 701, the second protocol field may have the following twocases:

Case m1: The second protocol field may be an SDAP field or a PDCP field.In this case, when the access device detects that the second timestampinformation is encapsulated in the NEW field in the received firstpacket, the access device extracts the second timestamp information fromthe NEW field, and then encapsulates the second timestamp information inan SDAP field or a PDCP field in a packet protocol field correspondingto the access device shown in FIG. 5, to generate the third packet. Inthis case, the SDAP field or the PDCP field in the third packet includesthe second timestamp information.

Certainly, in addition to the SDAP field or the PDCP field, the secondprotocol field may be any other field in the packet protocol fieldcorresponding to the access device shown in FIG. 5. This is not limitedin this application. When the second protocol field is another protocolfield, details are not described herein again.

Case m2: Same as Case k2, reference may be made to each other. Detailsare not described herein again.

For example, when the first packet carries the flag, in Cases j1, j2,k1, k2, l1, l2, m1, and m2, the access device may perform the foregoingprocess when detecting that the first protocol field in the first packetincludes the flag. For example, the access device may extract the flagfrom the first protocol field, and also encapsulate the flag in thesecond protocol field.

For example, after the second device receives the third packet, thesecond device extracts the second timestamp information carried in thesecond protocol field included in the third packet. For example, basedon the various cases of the second protocol field described above, theremay be the following three cases:

Case n1: The second device extracts the second timestamp informationfrom the GTP field. In this case, the second device is the user planenetwork element, and a packet protocol field corresponding to the seconddevice is a field corresponding to the user plane network element shownin FIG. 5.

Case n2: The second device extracts the second timestamp informationfrom the SDAP field or the PDCP field. In this case, the second deviceis the terminal device, and a packet protocol field corresponding to thesecond device is a field corresponding to the terminal device shown inFIG. 5.

Case n3: The second device extracts the second timestamp informationfrom the NEW field. In this case, the second device is the terminaldevice or the user plane network element. When the second device is theterminal device, a packet protocol field corresponding to the seconddevice is a field corresponding to the terminal device shown in FIG. 6.When the second device is the user plane network element, a packetprotocol field corresponding to the second device is a fieldcorresponding to the user plane network element shown in FIG. 6.

In an embodiment, when the access device detects that the first protocolfield is the NEW field, or when the second timestamp information isencapsulated in the NEW field, the access device may not process thefirst packet, but directly forwards the first packet to the seconddevice. In this case, the first packet is the third packet. In this way,after the second device receives the third packet, the second device maydirectly extract the second timestamp information from the firstprotocol field (namely, the NEW field). In this case, the packetprotocol field corresponding to the second device is the fieldcorresponding to the user plane network element or the terminal deviceshown in FIG. 6. In this process, a packet protocol field correspondingto the access device is a field corresponding to the access device shownin FIG. 5.

Operation 703: The second device determines fifth timestamp informationand sixth timestamp information, where the fifth timestamp informationis a moment that is in the Ethernet network and at which the seconddevice receives the third packet, and the sixth timestamp information isa moment that is in the mobile network and at which the second devicereceives the third packet.

For example, the moment corresponding to the fifth timestamp informationmay be t2 in FIG. 4, and the moment corresponding to the sixth timestampinformation may be t2′ in FIG. 4.

Operation 704: The second device sends a fourth packet to the accessdevice.

The fourth packet may not carry any timestamp information, and is merelyused as a packet in a synchronization procedure to identify time pointsof receiving and sending packets. For example, timestamp information inoperation 705 is obtained based on the fourth packet.

Operation 705: The second device determines seventh timestampinformation and eighth timestamp information, where the seventhtimestamp information is a moment that is in the Ethernet network and atwhich the second device sends the fourth packet to the access device,and the eighth timestamp information is a moment that is in the mobilenetwork and at which the second device sends the fourth packet to theaccess device.

For example, the moment corresponding to the seventh timestampinformation may be t3 in FIG. 4, and the moment corresponding to theeighth timestamp information may be t3′ in FIG. 4.

Operation 706: The access device sends a second packet to the firstdevice based on the fourth packet.

When the access device performs operation 706, the method may be: Theaccess device forwards the fourth packet to the first device. In thiscase, the fourth packet is the second packet.

Operation 707: After receiving the second packet, the first devicedetermines third timestamp information and fourth timestamp information,where the third timestamp information is a moment that is in theEthernet network and at which the first device receives the secondpacket, and the fourth timestamp information is a moment that is in themobile network and at which the first device receives the second packet.

For example, the moment corresponding to the third timestamp informationmay be t4 in FIG. 4, and the moment corresponding to the fourthtimestamp information may be t4′ in FIG. 4.

Operation 708: The first device sends the third timestamp informationand the fourth timestamp information to the access device.

For example, when the first device performs operation 708, a method maybe: The first device sends a fifth packet to the access device, wherethe fifth packet carries the third timestamp information and the fourthtimestamp information.

A case in which the fifth packet carries the fourth timestampinformation and a principle of processing the fifth packet by the firstdevice are the same as a case in which the first packet carries thesecond timestamp in operation 701 and a principle of processing thefirst packet by the first device. For details, reference may be made toeach other. The details are not described herein again.

Operation 709: The access device sends the third timestamp informationand the fourth timestamp information to the second device.

For example, a method in which the access device performs operation 709may be: The access device sends a sixth packet to the second devicebased on the fifth packet, where the sixth packet carries the thirdtimestamp information and the fourth timestamp information.

A case in which the sixth packet carries the fourth timestampinformation and a principle of processing the fifth packet by the accessdevice to generate the sixth packet are the same as a case in which thethird packet carries the second timestamp information in operation 702and a principle of processing the first packet by the access device togenerate the third packet. For details, reference may be made to eachother. The details are not described herein again.

Operation 710: The second device determines a time offset between thefirst device and the second device based on the first timestampinformation, the second timestamp information, the sixth timestampinformation, the eighth timestamp information, the third timestampinformation, the fourth timestamp information, the fifth timestampinformation, and the seventh timestamp information, and performs timesynchronization based on the time offset.

In an embodiment, when the second device performs operation 710, amethod may be: The second device determines a round-trip transmissiondelay difference between the first device and the second device based onthe second timestamp information (t1′), the sixth timestamp information(t2′), the eighth timestamp information (t3′), and the fourth timestampinformation (t4′). The second device determines a time offset betweenthe first device and the second device based on the first timestampinformation (t1), the third timestamp information (t4), the fifthtimestamp information (t2), the seventh timestamp information (t3), andthe round-trip transmission delay difference.

For example, for a process of calculating the round-trip transmissiondelay difference, refer to Formula 1 and Formula 2 in the embodimentshown in FIG. 3. Therefore, the round-trip transmission delay differenceis obtained through calculation, that is, delay 1−delay2=t2′−t1′−t4′+t3′. For details, refer to the detailed process inoperation 308. The details are not described herein again.

In an embodiment, a method in which the second device determines thetime offset between the first device and the second device based on thefirst timestamp information, the third timestamp information, the fifthtimestamp information, the seventh timestamp information, and theround-trip transmission delay difference may be: The second devicedetermines ninth timestamp information, where the ninth timestampinformation is a sum of the moment corresponding to the third timestampinformation and the round-trip transmission delay difference. The seconddevice determines the time offset between the first device and thesecond device based on the first timestamp information, the fifthtimestamp information, the seventh timestamp information, and the ninthtimestamp information.

For example, based on the obtained round-trip transmission delaydifference, it can be learned that a moment corresponding to the ninthtimestamp information is t4+t2′−t1′−t4′+t3′.

For example, the time offset between the first device and the seconddevice may still satisfy Formula 3 in the embodiment shown in FIG. 3.Details are not described herein again.

It should be noted that all packets in an embodiment are 802.1ASprotocol packets.

In an embodiment, when the timestamp information corresponding to themoment in the mobile network is carried in any one of the GTP field, theSDAP field, the NEW field, and the like in the packet, N bytes may bereserved in a corresponding protocol field to store the timestampinformation. For example, N is a positive integer, for example, N is 10.For example, when the protocol field carries both the timestampinformation and the flag, M bytes are reserved in the protocol field tostore the flag, where M is a positive integer. For example, M is 1.

According to the synchronization method provided in an embodiment ofthis application, the second device calculates the time offset betweenthe first device and the second device by using timestamp information ofreceiving and sending packets in the mobile network and timestampinformation of receiving and sending packets in the Ethernet network, toperform time synchronization. In the method, impact of a transmissiondelay between the first device and the second device can be avoided, sothat a time precision requirement of an industrial factory can be met ina scenario in which the mobile network is connected to the Ethernetnetwork.

An embodiment of this application further provides anothersynchronization method, which is applicable to the communicationssystems shown in FIG. 1 and FIG. 2. For example, in FIG. 8, a firstdevice is the UPF and a second device is the UE, or the first device isthe UE and the second device is the UPF. Referring to FIG. 8, aprocedure of the method may include the following operations.

Operation 801: The first device sends a first packet to an accessdevice, where the first packet carries first timestamp information andsecond timestamp information, the first timestamp information is amoment that is in an Ethernet network and at which the first devicesends the first packet, and the second timestamp information is a momentthat is in a mobile network and at which the first device sends thefirst packet.

In an embodiment, before the first device sends the first packet to theaccess device, the first device receives a data packet from the Ethernetnetwork (for example, a TSN). After the first device identifies that thedata packet is an 802.1AS frequency synchronization data packet, thefirst device sends the first packet to the access device, and in thiscase, initiates a clock synchronization procedure (herein referred to asa frequency synchronization procedure).

For example, FIG. 9 is a schematic diagram of packet receiving andsending in a process of performing frequency synchronization between thefirst device and the second device. In FIG. 9, a solid line indicates atransmission status of a packet in the Ethernet network, and a dashedline indicates a transmission status of a packet in the mobile network.It should be understood that in FIG. 9, a solid line and a dashed linethat are parallel in a same direction indicate transmission of a samepacket.

For example, in operation 801, the moment corresponding to the firsttimestamp information is denoted as t5 in FIG. 9, and the secondtimestamp information is denoted as t5′ in FIG. 9.

The first device is a user plane network element and the second deviceis a terminal device, or the first device is a terminal device and thesecond device is a user plane network element. In other words, either ofthe user plane network element and the terminal device may be a masterclock node, and the other needs to perform clock synchronization.

For example, the first packet may further carry a flag, and the flag isused to indicate that the first packet carries timestamp informationindicating a moment in the mobile network.

In an embodiment, a implementation method in which the first packetcarries the second timestamp information may be: The first device uses afirst protocol field included in the first packet to carry the secondtimestamp information. For example, the first protocol field may be anexisting protocol field in the first packet in a current protocol stackframework. Alternatively, the first protocol field may be a protocolfield newly added to the first packet in a current protocol stackframework. For example, when the first packet further carries a flag,the flag may also be carried in the first protocol field.

For example, the first protocol field may be the same as the firstprotocol field in operation 701 in the embodiment shown in FIG. 7. Fordetailed descriptions of the first protocol field, refer to the relateddescriptions in operation 701. No repeated description is providedherein.

Operation 802: The access device sends a third packet to the seconddevice based on the first packet, where the third packet carries thefirst timestamp information and the second timestamp information.

In an embodiment, a method in which the access device sends the thirdpacket to the second device based on the first packet may be: When theaccess device detects that a first protocol field included in the firstpacket includes the second timestamp information, the access deviceencapsulates the second timestamp information in a third protocol fieldincluded in the first packet to generate the third packet, and sends thethird packet to the second device.

For example, the first protocol field is the same as the first protocolfield in operation 801. For details, also refer to the relateddescriptions in operation 701. The third protocol field may also be anexisting protocol field, or may be a newly added field in an existingprotocol stack framework. For example, an execution principle of sendingthe third packet by the access device to the second device based on thefirst packet is the same as the principle of sending the third packet bythe access device to the second device based on the first packet inoperation 702 in the embodiment shown in FIG. 7. For details, refer tothe related principle in operation 702. The third protocol field may bethe same as the second protocol field in operation 702. For details,reference may be made to each other. The details are not describedherein again.

Operation 803: The second device determines fifth timestamp informationand sixth timestamp information, where the fifth timestamp informationis a moment that is in the Ethernet network and at which the seconddevice receives the third packet, and the sixth timestamp information isa moment that is in the mobile network and at which the second devicereceives the third packet.

For example, the moment corresponding to the fifth timestamp informationmay be t6 in FIG. 9, and the moment corresponding to the sixth timestampinformation may be t6′ in FIG. 9.

Operation 804: The first device sends a second packet to the accessdevice, where the second packet carries third timestamp information andfourth timestamp information, the third timestamp information is amoment that is in the Ethernet network and at which the first devicesends the second packet, and the fourth timestamp information is amoment that is in the mobile network and at which the first device sendsthe second packet.

For example, the moment corresponding to the third timestamp informationmay be t8 in FIG. 9, and the moment corresponding to the fourthtimestamp information may be t8′ in FIG. 9.

For example, a implementation method in which the second packet carriesthe fourth timestamp information may be: The first device uses a secondprotocol field included in the second packet to carry the fourthtimestamp information. For example, the second protocol field may be anexisting protocol field in the second packet in a current protocol stackframework. Alternatively, the second protocol field may be a protocolfield newly added to the second packet in a current protocol stackframework. For example, when the second packet further carries a flag,the flag may also be carried in the second protocol field.

For example, the second protocol field may be the same as the firstprotocol field in operation 701 in the embodiment shown in FIG. 7. Fordetailed descriptions of the second protocol field, refer to the relateddescriptions of the first protocol field in operation 701. No repeateddescription is provided herein.

Operation 805: The access device sends a fourth packet to the seconddevice based on the second packet, where the fourth packet carries thethird timestamp information and the fourth timestamp information.

In an embodiment, a method in which the access device sends the fourthpacket to the second device based on the second packet may be: When theaccess device detects that a second protocol field included in thesecond packet includes the fourth timestamp information, the accessdevice encapsulates the fourth timestamp information in a fourthprotocol field in the second packet to generate the fourth packet, andsends the fourth packet to the second device.

For example, the second protocol field is the same as the secondprotocol field in operation 804. For details, also refer to the relateddescriptions of the first protocol field in operation 701. The fourthprotocol field may also be an existing protocol field, or may be a newlyadded field in an existing protocol stack framework. For example, anexecution principle of sending the fourth packet by the access device tothe second device based on the second packet is the same as theprinciple of sending the third packet by the access device to the seconddevice based on the first packet in operation 702 in the embodimentshown in FIG. 7. For details, refer to the related principle inoperation 702. The fourth protocol field may be the same as the secondprotocol field in operation 702. For details, reference may be made toeach other. The details are not described herein again.

Operation 806: The second device determines seventh timestampinformation and eighth timestamp information, where the seventhtimestamp information is a moment that is in the Ethernet network and atwhich the second device receives the fourth packet, and the eighthtimestamp information is a moment that is in the mobile network and atwhich the second device receives the fourth packet.

For example, the moment corresponding to the seventh timestampinformation may be t7 in FIG. 9, and the moment corresponding to theeighth timestamp information may be t7′ in FIG. 9.

Operation 807: The second device determines a frequency offset betweenthe first device and the second device based on the first timestampinformation, the second timestamp information, the third timestampinformation, the fourth timestamp information, the fifth timestampinformation, the sixth timestamp information, the seventh timestampinformation, and the eighth timestamp information, and performsfrequency synchronization based on the frequency offset.

In an embodiment, a method in which the second device determines thefrequency offset between the first device and the second device based onthe first timestamp information (t5), the second timestamp information(t5′), the third timestamp information (t8), the fourth timestampinformation (t8′), the fifth timestamp information (t6), the sixthtimestamp information (t6′), the seventh timestamp information (t7), andthe eighth timestamp information (t7′) may be: The second devicedetermines a first difference between the moment corresponding to thesixth timestamp information and the moment corresponding to the secondtimestamp information, and determines a second difference between themoment corresponding to the eighth timestamp information and the momentcorresponding to the fourth timestamp information. The second devicedetermines the frequency offset between the first device and the seconddevice based on the first timestamp information, the third timestampinformation, the fifth timestamp information, the seventh timestampinformation, the first difference, and the second difference. Forexample, the first difference may be denoted as t6′−t5′, and the seconddifference may be denoted as t7′−t8′.

In an embodiment, a method in which the second device determines thefrequency offset between the first device and the second device based onthe first timestamp information, the third timestamp information, thefifth timestamp information, the seventh timestamp information, thefirst difference, and the second difference may be:

The second device determines a value relationship between the firstdifference and the second difference.

When the second device determines that the second difference is lessthan the first difference, the second device determines that thefrequency offset is a quotient of a first value and a second value,where the first value is a difference between the moment correspondingto the third timestamp information and the moment corresponding to thefirst timestamp information, the second value is a value obtained byadding a third value to a difference between the moment corresponding tothe seventh timestamp information and the moment corresponding to thefifth timestamp information, the third value is a product value of afourth value and a fifth value, the fourth value is a value obtained bysubtracting the second difference from the first difference, and thefifth value is a value obtained by dividing the difference between themoment corresponding to the seventh timestamp information and the momentcorresponding to the fifth timestamp by a difference between the momentcorresponding to the eighth timestamp information and the momentcorresponding to the sixth timestamp.

When the second device determines that the second difference is greaterthan the first difference, the second device determines that thefrequency offset is a quotient of the first value and a sixth value,where the sixth value is a value obtained by subtracting a seventh valuefrom a difference between the moment corresponding to the seventhtimestamp information and the moment corresponding to the fifthtimestamp information, the seventh value is a product value of an eighthvalue and the fifth value, and the eighth value is a value obtained bysubtracting the first difference from the second difference.

For example, when the first difference is less than the seconddifference, in this scenario, it may be considered that packets (namely,the second packet and the fourth packet) in a second procedure forperforming frequency synchronization arrive at the second deviceearlier. Therefore, the second device needs to wait for a moment atwhich delay differences in the mobile network are the same beforecalculating the frequency offset, in other words, performs the foregoingcorresponding operation. For example, the first value may be denoted ast8−t5, the third value may be denoted as[(t6′−t5′)−(t7′−t8′)]×[(t7−t6)/(t7′−t6′)], and the second value may bedenoted as t7−t6+[(t6′−t5′)−(t7′−t8′)]×[(t7−t6)/(t7′−t6′)]. For example,the frequency offset rate ratio may satisfy Formula 4:

$\begin{matrix}{{rateratio} = {\frac{{t\; 8} - {t\; 5}}{\begin{matrix}{{t\; 7} - {t\; 6} + {\left\lbrack {\left( {t\; 6^{\prime}t\; 5^{\prime}} \right) - \left( {{t\; 7^{\prime}} - {t\; 8^{\prime}}} \right)} \right\rbrack*}} \\\left\lbrack {\left( {{t\; 7} - {t\; 6}} \right)\text{/}\left( {{t\; 7^{\prime}} - {t\; 6^{\prime}}} \right)} \right\rbrack\end{matrix}}.}} & {{Formula}\mspace{14mu} 4}\end{matrix}$

For example, when the first difference is greater than the seconddifference, in this scenario, it may be considered that packets (namely,the second packet and the fourth packet) in a second procedure forperforming frequency synchronization arrive at the second device late.Therefore, the second device needs to go back to a moment at which delaydifferences in the mobile network are the same to calculate thefrequency offset, in other words, performs the foregoing correspondingoperation. For example, the first value may be denoted as t8−t5, theseventh value may be denoted as[(t7′−t8′)−(t6′−t5′)]×[(t7−t6)/(t7′−t6′)], and the sixth value may bedenoted as t7−t6−[(t7′−t8′)−(t6′−t5′)]×[(t7−t6)/(t7′−t6′)]. For example,the frequency offset rate ratio may satisfy Formula 5:

$\begin{matrix}{{rateratio} = {\frac{{t\; 8} - {t\; 5}}{\begin{matrix}{{t\; 7} - {t\; 6} - {\left\lbrack {\left( {{t\; 7^{\prime}} - {t\; 8^{\prime}}} \right) - \left( {{t\; 6^{\prime}} - {t\; 5^{\prime}}} \right)} \right\rbrack*}} \\\left\lbrack {\left( {{t\; 7} - {t\; 6}} \right)\text{/}\left( {{t\; 7^{\prime}} - {t\; 6^{\prime}}} \right)} \right\rbrack\end{matrix}}.}} & {{Formula}\mspace{14mu} 5}\end{matrix}$

In an embodiment, when the first difference is equal to the seconddifference, in this scenario, absolute delay differences in two times ofpacket receiving and sending in frequency synchronization are the same(that is, delay differences in the mobile network are the same). Thefrequency offset may be calculated by using Formula 4 or Formula 5. Whenthe first difference is equal to the second difference, a differencebetween the first difference and the second difference is 0. Therefore,the frequency offset may be directly calculated by using Formula 6:

$\begin{matrix}{{rateratio} = {\frac{{t\; 8} - {t\; 5}}{{t\; 7} - {t\; 6}}.}} & {{Formula}\mspace{14mu} 6}\end{matrix}$

According to the synchronization method provided in an embodiment ofthis application, the second device calculates the frequency offsetbetween the first device and the second device by using time points ofreceiving and sending packets in the mobile network and time points ofreceiving and sending packets in the Ethernet network during packettransmission initiated by the first device, to perform frequencysynchronization. In the method, impact of a transmission delay betweenthe first device and the second device can be avoided, so that a clockprecision requirement of an industrial factory can be met in a scenarioin which the mobile network is connected to the Ethernet network.

An embodiment of this application further provides anothersynchronization method, which is applicable to the communicationssystems shown in FIG. 1 and FIG. 2. For example, in FIG. 10, a firstdevice is the UPF and a second device is the UE, or the first device isthe UE and the second device is the UPF. Referring to FIG. 10, aprocedure of the method may include the following operations.

Operation 1001: The first device determines first timestamp information,where the first timestamp information is a difference between a momentcorresponding to second timestamp information and a moment correspondingto third timestamp information, the second timestamp information ismaster clock information in an Ethernet network, and the third timestampinformation is master clock information in a mobile network.

In an embodiment, the first device identifies a data packet from theEthernet network (for example, a TSN). If the first device identifiesthat format (type) information of the data packet is 0x88f7, the firstdevice determines that the data packet is an 802.1AS synchronizationdata packet. Then, the first device performs operation 1001, and in thiscase, initiates a clock synchronization procedure.

For example, the moment corresponding to the second timestampinformation may be denoted as T2, the moment corresponding to the thirdtimestamp information may be denoted as T1, and the first timestampinformation is denoted as T1−T2.

In an embodiment, the first device includes two layers of chips. Onelayer of chip identifies a moment in the mobile network, and the otherlayer of chip identifies a moment in the Ethernet network. Whendetermining the first timestamp information, the first device mayidentify the master clock information in the mobile network and themaster clock information in the Ethernet network by using the two layersof chips, to determine the difference between the master clockinformation.

Operation 1002: The first device sends a first packet to an accessdevice, where the first packet carries the first timestamp information.

For example, when sending the first packet to the access device, thefirst device may use synchronization request (sync request) signaling tocarry the first timestamp information.

In an embodiment, a implementation in which the first packet carries thefirst timestamp information may be: The first device uses a firstprotocol field included in the first packet to carry the first timestampinformation. For example, the first protocol field may be an existingprotocol field in the first packet in a current protocol stackframework. Alternatively, the first protocol field may be a protocolfield newly added to the first packet in a current protocol stackframework.

For example, the first protocol field may be the same as the firstprotocol field in operation 701 in the embodiment shown in FIG. 7. Fordetailed descriptions of the first protocol field, refer to the relateddescriptions in operation 701. No repeated description is providedherein.

Operation 1003: The access device sends a third packet to the seconddevice based on the first packet, where the third packet carries thefirst timestamp information.

For example, a method in which the access device sends the third packetto the second device based on the first packet may be: When the accessdevice detects that a first protocol field included in the first packetincludes the first timestamp information, the access device encapsulatesthe first timestamp information in a second protocol field included inthe first packet to generate the third packet, and sends the thirdpacket to the second device.

For example, the first protocol field is the same as the first protocolfield in operation 1001. For details, also refer to the relateddescriptions in operation 701. The second protocol field may also be anexisting protocol field, or may be a newly added field in an existingprotocol stack framework. For example, an execution principle of sendingthe third packet by the access device to the second device based on thefirst packet is the same as the principle of sending the third packet bythe access device to the second device based on the first packet inoperation 702 in the embodiment shown in FIG. 7. For details, refer tothe related principle in operation 702. The second protocol field may bethe same as the second protocol field in operation 702. For details,reference may be made to each other. The details are not describedherein again.

For example, after the second device receives the third packet from theaccess device, the second device extracts the first timestampinformation carried in a second protocol field included in the thirdpacket. For example, for details, refer to Cases n1, n2, and n3 inoperation 702. The details are not described herein again.

Operation 1004: The second device determines fourth timestampinformation, where the fourth timestamp information is a moment that isin the mobile network and at which the second device receives the thirdpacket.

In a possible example, the moment corresponding to the fourth timestampinformation may be denoted as T2′.

Operation 1005: The second device completes time synchronization byadding the difference corresponding to the first timestamp informationto the moment corresponding to the fourth timestamp information.

For example, a process in which the second device performs operation1005 may be: Time synchronization is completed by using T2′+(T1−T2).

Operation 1006: The second device sends a second packet to the accessdevice, where the second packet is used to notify the first device thattime synchronization is completed.

Operation 1007: The access device sends the second packet to the firstdevice.

Operation 1006 and operation 1007 are optional, and are shown in dashedlines in FIG. 10. After operation 1006 and operation 1007 are performed,the first device can terminate transmission of a packet after the thirdpacket in an existing synchronization procedure by identifying that timesynchronization is completed, thereby reducing resource consumption.

According to the synchronization method provided in an embodiment ofthis application, the first device determines a difference between themaster clock information in the mobile network and the master clockinformation in the Ethernet network, and sends the difference to thesecond device, so that the second device directly completes clocksynchronization by using the difference between the master clockinformation. In the method, impact of a transmission delay between thefirst device and the second device can be avoided, so that a timeprecision requirement of an industrial factory can be met in a scenarioin which the mobile network is connected to the Ethernet network.

Based on the foregoing embodiments, this application further provides afirst device. The first device may be applied to the communicationssystem shown in FIG. 1 or FIG. 2, and is configured to implement thesynchronization method provided in the embodiment shown in FIG. 3. FIG.11 shows a structure of the first device. Referring to FIG. 11, thefirst device includes a sending unit 1101, a processing unit 1102, and areceiving unit 1103.

The sending unit 1101 is configured to send a first packet to an accessdevice, where the first packet carries first timestamp information, andthe first timestamp information is a moment that is in an Ethernetnetwork and at which the first device sends the first packet.

The processing unit 1102 is configured to determine second timestampinformation, where the second timestamp information is a moment that isin a mobile network and at which the first device sends the firstpacket.

The receiving unit 1103 is configured to receive a second packet fromthe access device, where the second packet carries third timestampinformation and fourth timestamp information, the third timestampinformation is a moment that is in the mobile network and at which asecond device receives a third packet sent by the access device to thesecond device based on the first packet, the fourth timestampinformation is a moment that is in the mobile network and at which thesecond device sends a fourth packet to the access device, and the secondpacket is sent by the access device to the first device based on thefourth packet.

The processing unit 1102 is further configured to determine fifthtimestamp information and sixth timestamp information, where the fifthtimestamp information is a moment that is in the Ethernet network and atwhich the first device receives the second packet, and the sixthtimestamp information is a moment that is in the mobile network and atwhich the first device receives the second packet.

The processing unit 1102 is further configured to determine seventhtimestamp information based on the second timestamp information, thethird timestamp information, the fourth timestamp information, the fifthtimestamp information, and the sixth timestamp information.

The sending unit 1101 is further configured to forward the seventhtimestamp information to the second device by using the access device.

The first device is a user plane network element and the second deviceis a terminal device, or the first device is a terminal device and thesecond device is a user plane network element.

In an embodiment, when determining the seventh timestamp informationbased on the second timestamp information, the third timestampinformation, the fourth timestamp information, the fifth timestampinformation, and the sixth timestamp information, the processing unit1102 is configured to:

determine a round-trip transmission delay difference between the firstdevice and the second device based on the second timestamp information,the third timestamp information, the fourth timestamp information, andthe sixth timestamp information; and

calculate a sum of the moment corresponding to the fifth timestampinformation and the round-trip transmission delay difference, to obtainthe seventh timestamp information.

In an embodiment, the processing unit 1102 is further configured to:after the receiving unit 1103 receives the second packet from the accessdevice, extract the third timestamp information and the fourth timestampinformation that are carried in a first protocol field included in thesecond packet.

In an embodiment, when the first device is the user plane networkelement, the first protocol field is a general packet radio service GPRStunneling protocol GTP field. When the first device is the terminaldevice, the first protocol field is a service data protocol SDAP fieldor a data convergence protocol PDCP field.

Based on the foregoing embodiments, this application further provides anaccess device. The access device may be applied to the communicationssystem shown in FIG. 1 or FIG. 2, and is configured to implement thesynchronization method provided in the embodiment shown in FIG. 3.Referring to FIG. 12, the access device includes a receiving unit 1201and a sending unit 1202.

The receiving unit 1201 is configured to receive a first packet from afirst device, where the first packet carries first timestampinformation, and the first timestamp information is a moment that is inan Ethernet network and at which the first device sends the firstpacket.

The sending unit 1202 is configured to send a third packet to a seconddevice based on the first packet, where the third packet carries thefirst timestamp information.

The receiving unit 1201 is further configured to receive a fourth packetfrom the second device, where the fourth packet carries third timestampinformation and fourth timestamp information, the third timestampinformation is a moment that is in the mobile network and at which thesecond device receives the third packet, and the fourth timestampinformation is a moment that is in the mobile network and at which thesecond device sends the fourth packet to the access device.

The sending unit 1202 is further configured to send a second packet tothe first device, where the second packet carries the third timestampinformation and the fourth timestamp information.

The receiving unit 1201 is further configured to receive seventhtimestamp information from the first device.

The sending unit 1202 is further configured to send the seventhtimestamp information to the second device.

The first device is a user plane network element and the second deviceis a terminal device, or the first device is a terminal device and thesecond device is a user plane network element.

In an embodiment, the access device further includes a processing unit,configured to: when detecting that a second protocol field included inthe fourth packet carries the third timestamp information and the fourthtimestamp information, encapsulate the third timestamp information andthe fourth timestamp information in a first protocol field included inthe fourth packet to generate the second packet. When sending the secondpacket to the first device, the sending unit 1202 is configured to: whenthe processing unit detects that the second protocol field included inthe fourth packet carries the third timestamp information and the fourthtimestamp information, after the processing unit encapsulates the thirdtimestamp information and the fourth timestamp information in the firstprotocol field included in the fourth packet to generate the secondpacket, send the second packet to the first device.

In an embodiment, when the first device is the user plane networkelement, the second protocol field is a service data protocol SDAP fieldor a data convergence protocol PDCP field, and the first protocol fieldis a general packet radio service GPRS tunneling protocol GTP field.

When the first device is the terminal device, the second protocol fieldis a GTP field, and the first protocol field is an SDAP field or a PDCPfield.

Based on the foregoing embodiments, this application further provides asecond device. The second device may be applied to the communicationssystem shown in FIG. 1 or FIG. 2, and is configured to implement thesynchronization method provided in the embodiment shown in FIG. 3.Referring to FIG. 13, the second device includes a receiving unit 1301,a processing unit 1302, and a sending unit 1303.

The receiving unit 1301 is configured to receive a third packet from anaccess device, where the third packet carries first timestampinformation, the first timestamp information is a moment that is in anEthernet network and at which a first device sends a first packet, andthe third packet is sent by the access device based on the first packetafter the access device receives the first packet from the first device.The first device is a user plane network element and the second deviceis a terminal device, or the first device is a terminal device and thesecond device is a user plane network element.

The processing unit 1302 is configured to determine third timestampinformation and eighth timestamp information, where the third timestampinformation is a moment that is in the mobile network and at which thesecond device receives the third packet, and the eighth timestampinformation is a moment that is in the Ethernet network and at which thesecond device receives the third packet.

The sending unit 1303 is configured to send a fourth packet to theaccess device, where the fourth packet carries the third timestampinformation and fourth timestamp information, and the fourth timestampinformation is a moment that is in the mobile network and at which thesecond device sends the fourth packet to the access device.

The processing unit 1302 is further configured to determine ninthtimestamp information, where the ninth timestamp information is a momentthat is in the Ethernet network and at which the second device sends thefourth packet to the access device.

The receiving unit 1301 is further configured to receive seventhtimestamp information from the access device.

The processing unit 1302 is further configured to: determine a timeoffset between the first device and the second device based on the firsttimestamp information, the eighth timestamp information, the ninthtimestamp information, and the seventh timestamp information, andperform time synchronization based on the time offset.

In an embodiment, the processing unit 1302 is further configured todetermine, based on the seventh timestamp information, a moment that isin the Ethernet network and at which the first device receives a secondpacket, where the second packet is sent by the access device to thefirst device based on the fourth packet.

In an embodiment, when the fourth packet carries the third timestampinformation and the fourth timestamp information, the sending unit 1303is configured to:

use a second protocol field included in the fourth packet to carry thethird timestamp information and the fourth timestamp information.

In an embodiment, when the second device is the terminal device, thesecond protocol field is a service data protocol SDAP field or a dataconvergence protocol PDCP field.

When the second device is the user plane network element, the secondprotocol field is a general packet radio service GPRS tunneling protocolGTP field.

Based on the foregoing embodiments, this application further provides afirst device. The first device may be applied to the communicationssystem shown in FIG. 1 or FIG. 2, and is configured to implement thesynchronization method provided in the embodiment shown in FIG. 7.Referring to FIG. 14, the first device includes a sending unit 1401 anda receiving unit 1402.

The sending unit 1401 is configured to send a first packet to an accessdevice, where the first packet carries first timestamp information andsecond timestamp information, the first timestamp information is amoment that is in an Ethernet network and at which the first devicesends the first packet, and the second timestamp information is a momentthat is in a mobile network and at which the first device sends thefirst packet.

The receiving unit 1402 is configured to: receive a second packet fromthe access device, and determine third timestamp information and fourthtimestamp information, where the third timestamp information is a momentthat is in the Ethernet network and at which the first device receivesthe second packet, and the fourth timestamp information is a moment thatis in the mobile network and at which the first device receives thesecond packet.

The sending unit 1401 is further configured to send the third timestampinformation and the fourth timestamp information to the access device,where the first timestamp information, the second timestamp information,the third timestamp information, and the fourth timestamp informationare used for time synchronization.

The first device is a user plane network element and the second deviceis a terminal device, or the first device is a terminal device and thesecond device is a user plane network element.

In an embodiment, when the first packet carries the second timestampinformation, the sending unit 1401 is configured to use a first protocolfield included in the first packet to carry the second timestampinformation.

In an embodiment, when the first device is the user plane networkelement, the first protocol field is a general packet radio service GPRStunneling protocol GTP field. When the first device is the terminaldevice, the first protocol field is a service data protocol SDAP fieldor a data convergence protocol PDCP field.

Based on the foregoing embodiments, this application further provides anaccess device. The access device may be applied to the communicationssystem shown in FIG. 1 or FIG. 2, and is configured to implement thesynchronization method provided in the embodiment shown in FIG. 7.Similarly, referring to FIG. 12, the access device includes a receivingunit 1201 and a sending unit 1202.

The receiving unit 1201 is configured to receive a first packet from afirst device, where the first packet carries first timestamp informationand second timestamp information, the first timestamp information is amoment that is in an Ethernet network and at which the first devicesends the first packet, and the second timestamp information is a momentthat is in a mobile network and at which the first device sends thefirst packet.

The sending unit 1202 is configured to send a third packet to a seconddevice based on the first packet, where the third packet carries thefirst timestamp information and the second timestamp information.

The receiving unit 1201 is further configured to: receive a fourthpacket from the second device, and send a second packet to the firstdevice based on the fourth packet.

The receiving unit 1201 is further configured to receive third timestampinformation and fourth timestamp information from the first device,where the third timestamp information is a moment that is in theEthernet network and at which the first device receives the secondpacket, and the fourth timestamp information is a moment that is in themobile network and at which the first device receives the second packet.

The sending unit 1202 is further configured to send the third timestampinformation and the fourth timestamp information to the second device,where the first timestamp information, the second timestamp information,the third timestamp information, and the fourth timestamp informationare used for time synchronization.

The first device is a user plane network element and the second deviceis a terminal device, or the first device is a terminal device and thesecond device is a user plane network element.

In an embodiment, the access device further includes a processing unit,configured to: when detecting that a first protocol field included inthe first packet includes the second timestamp information, encapsulate,by the access device, the second timestamp information in a secondprotocol field included in the first packet to generate the thirdpacket. When sending the third packet to the second device based on thefirst packet, the sending unit 1202 is configured to: when theprocessing unit detects that the first protocol field included in thefirst packet includes the second timestamp information, after the accessdevice encapsulates the second timestamp information in the secondprotocol field included in the first packet to generate the thirdpacket, send the third packet to the second device.

In an embodiment, when the first device is the user plane networkelement, and the second device is the terminal device, the firstprotocol field is a GTP field, and the second protocol field is a SDAPfield or a PDCP field. When the first device is the terminal device, andthe second device is the user plane network element, the first protocolfield is an SDAP field or a PDCP field, and the second protocol field isa GTP field.

Based on the foregoing embodiments, this application further provides asecond device. The second device may be applied to the communicationssystem shown in FIG. 1 or FIG. 2, and is configured to implement thesynchronization method provided in the embodiment shown in FIG. 7.Similarly, referring to FIG. 13, the second device includes a receivingunit 1301, a processing unit 1302, and a sending unit 1303.

The receiving unit 1301 is configured to receive a third packet from anaccess device, where the third packet carries first timestampinformation and second timestamp information, the first timestampinformation is a moment that is in an Ethernet network and at which afirst device sends a first packet, the second timestamp information is amoment that is in a mobile network and at which the first device sendsthe first packet, and the third packet is sent by the access devicebased on the first packet after the access device receives the firstpacket from the first device. The first device is a user plane networkelement and the second device is a terminal device, or the first deviceis a terminal device and the second device is a user plane networkelement.

The processing unit 1302 is configured to determine fifth timestampinformation and sixth timestamp information, where the fifth timestampinformation is a moment that is in the Ethernet network and at which thesecond device receives the third packet, and the sixth timestampinformation is a moment that is in the mobile network and at which thesecond device receives the third packet.

The sending unit 1303 is configured to: send a fourth packet to theaccess device, and determine seventh timestamp information and eighthtimestamp information, where the seventh timestamp information is amoment that is in the Ethernet network and at which the second devicesends the fourth packet to the access device, and the eighth timestampinformation is a moment that is in the mobile network and at which thesecond device sends the fourth packet to the access device.

The receiving unit 1301 is further configured to receive third timestampinformation and fourth timestamp information from the access device,where the third timestamp information is a moment that is in theEthernet network and at which the first device receives a second packet,the fourth timestamp information is a moment that is in the mobilenetwork and at which the first device receives the second packet, andthe second packet is sent by the access device to the first device basedon the fourth packet.

The processing unit 1302 is further configured to: determine a timeoffset between the first device and the second device based on the firsttimestamp information, the second timestamp information, the sixthtimestamp information, the eighth timestamp information, the thirdtimestamp information, the fourth timestamp information, the fifthtimestamp information, and the seventh timestamp information, andperform time synchronization based on the time offset.

In an embodiment, when determining the time offset between the firstdevice and the second device based on the first timestamp information,the second timestamp information, the sixth timestamp information, theeighth timestamp information, the third timestamp information, thefourth timestamp information, the fifth timestamp information, and theseventh timestamp information, the processing unit 1302 is configuredto:

determine a round-trip transmission delay difference between the firstdevice and the second device based on the second timestamp information,the sixth timestamp information, the eighth timestamp information, andthe fourth timestamp information; and

determine the time offset between the first device and the second devicebased on the first timestamp information, the third timestampinformation, the fifth timestamp information, the seventh timestampinformation, and the round-trip transmission delay difference.

In an embodiment, when determining the time offset between the firstdevice and the second device based on the first timestamp information,the third timestamp information, the fifth timestamp information, theseventh timestamp information, and the round-trip transmission delaydifference, the processing unit 1302 is configured to:

determine ninth timestamp information, where the ninth timestampinformation is a sum of the moment corresponding to the third timestampinformation and the round-trip transmission delay difference; and

determine the time offset between the first device and the second devicebased on the first timestamp information, the fifth timestampinformation, the seventh timestamp information, and the ninth timestampinformation.

In an embodiment, the processing unit 1302 is further configured to:after the receiving unit 1301 receives the third packet from the accessdevice, extract the second timestamp information carried in a secondprotocol field included in the third packet.

In an embodiment, when the second device is the terminal device, thesecond protocol field is a SDAP field or a PDCP field. When the seconddevice is the user plane network element, the second protocol field is aGTP field.

Based on the foregoing embodiments, this application further provides afirst device. The first device may be applied to the communicationssystem shown in FIG. 1 or FIG. 2, and is configured to implement thesynchronization method provided in the embodiment shown in FIG. 8.Referring to FIG. 15, the first device includes a sending unit 1501 anda processing unit 1502.

The sending unit 1501 is configured to send a first packet to an accessdevice, where the first packet carries first timestamp information andsecond timestamp information, the first timestamp information is amoment that is in an Ethernet network and at which the first devicesends the first packet, and the second timestamp information is a momentthat is in a mobile network and at which the first device sends thefirst packet.

The sending unit 1501 is further configured to send a second packet tothe access device, where the second packet carries third timestampinformation and fourth timestamp information, the third timestampinformation is a moment that is in the Ethernet network and at which thefirst device sends the second packet, and the fourth timestampinformation is a moment that is in the mobile network and at which thefirst device sends the second packet.

The processing unit 1502 is configured to control the sending unit 1501to send data.

The first device is a user plane network element and a second device isa terminal device, or the first device is a terminal device and thesecond device is a user plane network element.

In an embodiment, when the first packet carries the second timestampinformation, the sending unit 1501 is configured to use a first protocolfield included in the first packet to carry the second timestampinformation.

In an embodiment, when the first device is the user plane networkelement, the first protocol field is a GTP field. When the first deviceis the terminal device, the first protocol field is a SDAP field or aPDCP field.

In an embodiment, when the second packet carries the fourth timestampinformation, the sending unit 1501 is configured to use a secondprotocol field included in the second packet to carry the fourthtimestamp information.

In an embodiment, when the first device is the user plane networkelement, the second protocol field is a GTP field. When the first deviceis the terminal device, the second protocol field is a SDAP field or aPDCP field.

Based on the foregoing embodiments, this application further provides anaccess device. The access device may be applied to the communicationssystem shown in FIG. 1 or FIG. 2, and is configured to implement thesynchronization method provided in the embodiment shown in FIG. 8.Similarly, referring to FIG. 12, the access device includes a receivingunit 1201 and a sending unit 1202.

The receiving unit 1201 is configured to receive a first packet from afirst device, where the first packet carries first timestamp informationand second timestamp information, the first timestamp information is amoment that is in an Ethernet network and at which the first devicesends the first packet, and the second timestamp information is a momentthat is in a mobile network and at which the first device sends thefirst packet.

The sending unit 1202 is configured to send a third packet to a seconddevice based on the first packet, where the third packet carries thefirst timestamp information and the second timestamp information.

The receiving unit 1201 is further configured to receive a second packetfrom the first device, where the second packet carries third timestampinformation and fourth timestamp information, the third timestampinformation is a moment that is in the Ethernet network and at which thefirst device sends the second packet, and the fourth timestampinformation is a moment that is in the mobile network and at which thefirst device sends the second packet.

The sending unit 1202 is further configured to send a fourth packet tothe second device based on the second packet, where the fourth packetcarries the third timestamp information and the fourth timestampinformation.

The first device is a user plane network element and the second deviceis a terminal device, or the first device is a terminal device and thesecond device is a user plane network element.

In an embodiment, the access device further includes a processing unit,configured to: when detecting that a first protocol field included inthe first packet includes the second timestamp information, encapsulate,by the access device, the second timestamp information in a thirdprotocol field included in the first packet to generate the thirdpacket. When sending the third packet to the second device based on thefirst packet, the sending unit 1202 is configured to: when theprocessing unit detects that the first protocol field included in thefirst packet includes the second timestamp information, after the accessdevice encapsulates the second timestamp information in the thirdprotocol field included in the first packet to generate the thirdpacket, send the third packet to the second device.

In an embodiment, when the first device is the user plane networkelement, and the second device is the terminal device, the firstprotocol field is a GTP field, and the third protocol field is a SDAPfield or a PDCP field. When the first device is the terminal device, andthe second device is the user plane network element, the first protocolfield is an SDAP field or a PDCP field, and the third protocol field isa GTP field.

In an embodiment, the access device further includes a processing unit,configured to: when detecting that a second protocol field included inthe second packet includes the fourth timestamp information,encapsulate, by the access device, the fourth timestamp information in afourth protocol field in the second packet to generate the fourthpacket. When sending the fourth packet to the second device based on thesecond packet, the sending unit 1202 is configured to: when theprocessing unit detects that the second protocol field included in thesecond packet includes the fourth timestamp information, after theaccess device encapsulates the fourth timestamp information in thefourth protocol field in the second packet to generate the fourthpacket, send the fourth packet to the second device.

In an embodiment, when the first device is the user plane networkelement, and the second device is the terminal device, the secondprotocol field is a GTP field, and the fourth protocol field is a SDAPfield or a PDCP field. When the first device is the terminal device, andthe second device is the user plane network element, the second protocolfield is an SDAP field or a PDCP field, and the fourth protocol field isa GTP field.

Based on the foregoing embodiments, this application further provides asecond device. The second device may be applied to the communicationssystem shown in FIG. 1 or FIG. 2, and is configured to implement thesynchronization method provided in the embodiment shown in FIG. 8.Referring to FIG. 16, the second device includes a receiving unit 1601and a processing unit 1602.

The receiving unit 1601 is configured to receive a third packet from anaccess device, where the third packet carries first timestampinformation and second timestamp information, the first timestampinformation is a moment that is in an Ethernet network and at which afirst device sends a first packet to the access device, the secondtimestamp information is a moment that is in a mobile network and atwhich the first device sends the first packet to the access device, andthe third packet is sent by the access device to the second device basedon the first packet. The first device is a user plane network elementand the second device is a terminal device, or the first device is aterminal device and the second device is a user plane network element.

The processing unit 1602 is configured to determine fifth timestampinformation and sixth timestamp information, where the fifth timestampinformation is a moment that is in the Ethernet network and at which thesecond device receives the third packet, and the sixth timestampinformation is a moment that is in the mobile network and at which thesecond device receives the third packet.

The receiving unit 1601 is configured to receive a fourth packet fromthe access device, where the fourth packet carries third timestampinformation and fourth timestamp information, the third timestampinformation is a moment that is in the Ethernet network and at which thefirst device sends a second packet to the access device, the fourthtimestamp information is a moment that is in the mobile network and atwhich the first device sends the second packet to the access device, andthe fourth packet is sent by the access device to the second devicebased on the second packet.

The processing unit 1602 is further configured to determine seventhtimestamp information and eighth timestamp information, where theseventh timestamp information is a moment that is in the Ethernetnetwork and at which the second device receives the fourth packet, andthe eighth timestamp information is a moment that is in the mobilenetwork and at which the second device receives the fourth packet.

The processing unit 1602 is further configured to: determine a frequencyoffset between the first device and the second device based on the firsttimestamp information, the second timestamp information, the thirdtimestamp information, the fourth timestamp information, the fifthtimestamp information, the sixth timestamp information, the seventhtimestamp information, and the eighth timestamp information, and performfrequency synchronization based on the frequency offset.

In an embodiment, when determining the frequency offset between thefirst device and the second device based on the first timestampinformation, the second timestamp information, the third timestampinformation, the fourth timestamp information, the fifth timestampinformation, the sixth timestamp information, the seventh timestampinformation, and the eighth timestamp information, the processing unit1602 is configured to:

determine a first difference between the moment corresponding to thesixth timestamp information and the moment corresponding to the secondtimestamp information, and determine a second difference between themoment corresponding to the eighth timestamp information and the momentcorresponding to the fourth timestamp information; and

determine the frequency offset between the first device and the seconddevice based on the first timestamp information, the third timestampinformation, the fifth timestamp information, the seventh timestampinformation, the first difference, and the second difference.

In an embodiment, when determining the frequency offset between thefirst device and the second device based on the first timestampinformation, the third timestamp information, the fifth timestampinformation, the seventh timestamp information, the first difference,and the second difference, the processing unit 1602 is configured to:

determine a value relationship between the first difference and thesecond difference; and

when determining that the second difference is less than the firstdifference, determine that the frequency offset is a quotient of a firstvalue and a second value, where the first value is a difference betweenthe moment corresponding to the third timestamp information and themoment corresponding to the first timestamp information, the secondvalue is a value obtained by adding a third value to a differencebetween the moment corresponding to the seventh timestamp informationand the moment corresponding to the fifth timestamp information, thethird value is a product value of a fourth value and a fifth value, thefourth value is a value obtained by subtracting the second differencefrom the first difference, and the fifth value is a value obtained bydividing the difference between the moment corresponding to the seventhtimestamp information and the moment corresponding to the fifthtimestamp by a difference between the moment corresponding to the eighthtimestamp information and the moment corresponding to the sixthtimestamp; or

when determining that the second difference is greater than the firstdifference, determine that the frequency offset is a quotient of thefirst value and a sixth value, where the sixth value is a value obtainedby subtracting a seventh value from a difference between the momentcorresponding to the seventh timestamp information and the momentcorresponding to the fifth timestamp information, the seventh value is aproduct value of an eighth value and the fifth value, and the eighthvalue is a value obtained by subtracting the first difference from thesecond difference.

Based on the foregoing embodiments, this application further provides afirst device. The first device may be applied to the communicationssystem shown in FIG. 1 or FIG. 2, and is configured to implement thesynchronization method provided in the embodiment shown in FIG. 10.Referring to FIG. 17, the first device includes a processing unit 1701and a sending unit 1702.

The processing unit 1701 is configured to determine first timestampinformation, where the first timestamp information is a differencebetween a moment corresponding to second timestamp information and amoment corresponding to third timestamp information, the secondtimestamp information is master clock information in an Ethernetnetwork, and the third timestamp information is master clock informationin a mobile network.

The sending unit 1702 is configured to send a first packet to an accessdevice, where the first packet carries the first timestamp information.

The first device is a user plane network element and a second device isa terminal device, or the first device is a terminal device and thesecond device is a user plane network element.

In an embodiment, when the first packet carries the first timestampinformation, the sending unit 1702 is configured to use a first protocolfield included in the first packet to carry the first timestampinformation.

In an embodiment, when the first device is the user plane networkelement, the first protocol field is a general packet radio service GPRStunneling protocol GTP field. When the first device is the terminaldevice, the first protocol field is a service data protocol SDAP fieldor a data convergence protocol PDCP field.

In an embodiment, the first device further includes a receiving unit,configured to receive a second packet from the access device, where thesecond packet is used to notify the first device that timesynchronization is completed.

Based on the foregoing embodiments, this application further provides anaccess device. The access device may be applied to the communicationssystem shown in FIG. 1 or FIG. 2, and is configured to implement thesynchronization method provided in the embodiment shown in FIG. 10.Similarly, referring to FIG. 12, the access device includes a receivingunit 1201 and a sending unit 1202.

The receiving unit 1201 is configured to receive a first packet from afirst device, where the first packet carries first timestampinformation, the first timestamp information is a difference between amoment corresponding to second timestamp information and a momentcorresponding to third timestamp information, the second timestampinformation is master clock information in an Ethernet network, and thethird timestamp information is master clock information in a mobilenetwork.

The sending unit 1202 is configured to send a third packet to a seconddevice based on the first packet, where the third packet carries thefirst timestamp information.

The first device is a user plane network element and the second deviceis a terminal device, or the first device is a terminal device and thesecond device is a user plane network element.

In an embodiment, the access device further includes a processing unit,configured to: when detecting that a first protocol field included inthe first packet includes the first timestamp information, encapsulate,by the access device, the first timestamp information in a secondprotocol field included in the first packet to generate the thirdpacket. When sending the third packet to the second device based on thefirst packet, the sending unit 1202 is configured to: when theprocessing unit detects that the first protocol field included in thefirst packet includes the first timestamp information, the access deviceencapsulates the first timestamp information in the second protocolfield included in the first packet to generate the third packet, sendthe third packet to the second device.

In an embodiment, when the first device is the user plane networkelement, and the second device is the terminal device, the firstprotocol field is a general packet radio service GPRS tunneling protocolGTP field, and the second protocol field is a service data protocol SDAPfield or a data convergence protocol PDCP field. When the first deviceis the terminal device, and the second device is the user plane networkelement, the first protocol field is an SDAP field or a PDCP field, andthe second protocol field is a GTP field.

In an embodiment, the receiving unit 1201 is further configured toreceive a second packet from the second device, and the sending unit1202 is further configured to forward the second packet to the firstdevice, where the second packet is used to notify the first device thattime synchronization is completed.

Based on the foregoing embodiments, this application further provides asecond device. The second device may be applied to the communicationssystem shown in FIG. 1 or FIG. 2, and is configured to implement thesynchronization method provided in the embodiment shown in FIG. 10.Referring to FIG. 16, the second device includes a receiving unit 1601and a processing unit 1602.

The receiving unit 1601 is configured to receive a third packet from anaccess device, where the third packet carries first timestampinformation, the first timestamp information is a difference between amoment corresponding to second timestamp information and a momentcorresponding to third timestamp information, and the second timestampinformation is master clock information in an Ethernet network, thethird timestamp information is master clock information in a mobilenetwork, the third packet is sent by the access device based on a firstpacket, and the first packet is sent by a first device to the accessdevice. The first device is a user plane network element and the seconddevice is a terminal device, or the first device is a terminal deviceand the second device is a user plane network element.

The processing unit 1602 is configured to determine fourth timestampinformation, where the fourth timestamp information is a moment that isin the mobile network and at which the second device receives the thirdpacket.

The processing unit 1602 is further configured to complete timesynchronization by adding the difference corresponding to the firsttimestamp information to the moment corresponding to the fourthtimestamp information.

In an embodiment, the processing unit 1602 is further configured to:after the receiving unit 1601 receives the third packet from the accessdevice, extract the first timestamp information carried in a secondprotocol field included in the third packet.

In an embodiment, when the second device is the terminal device, thesecond protocol field is a SDAP field or a PDCP field. When the seconddevice is the user plane network element, the second protocol field is aGTP field.

In an embodiment, the second device further includes a sending unit,configured to send a second packet to the access device, where thesecond packet is used to notify the first device that timesynchronization is completed.

It should be noted that in the embodiments of this application, divisioninto the units is an example and is merely logical function division,and may be other division in an actual implementation. Function units inthe embodiments of this application may be integrated into oneprocessing unit, or each of the units may exist alone physically, or twoor more units are integrated into one unit. The integrated unit may beimplemented in a form of hardware, or may be implemented in a form of asoftware function unit.

When the integrated unit is implemented in the form of a softwarefunction unit and sold or used as an independent product, the integratedunit may be stored in a computer readable storage medium. Based on suchan understanding, the technical solutions of this applicationessentially, or the part contributing to the prior art, or all or someof the technical solutions may be implemented in the form of a computersoftware product. The computer software product is stored in a storagemedium and includes several instructions for instructing a computerdevice (which may be a personal computer, a server, a network device, orthe like) or a processor to perform all or some of the operations of themethods in the embodiments of this application. The foregoing storagemedium includes any medium that can store program code, such as a USBflash drive, a removable hard disk, a read-only memory (ROM), a randomaccess memory (RAM), a magnetic disk, or an optical disc.

Based on the foregoing embodiments, an embodiment of this applicationfurther provides a first device. The first device is applied to thecommunications system shown in FIG. 1 or FIG. 2, and is configured toimplement the synchronization method shown in FIG. 3. Referring to FIG.18, the first device includes a transceiver 1801, a processor 1802, anda memory 1803.

The processor 1802 may be a central processing unit (CPU), a networkprocessor (NP), a combination of a CPU and an NP, or the like. Theprocessor 1802 may further include a hardware chip. The hardware chipmay be an application-specific integrated circuit (ASIC), a programmablelogic device (PLD), or a combination thereof. The PLD may be a complexprogrammable logic device (CPLD), a field-programmable gate array(FPGA), a generic array logic (GAL), or any combination thereof. Theprocessor 1802 may implement the foregoing functions by hardware orcertainly by hardware executing corresponding software.

The transceiver 1801, the processor 1802, and the memory 1803 areconnected to each other. For example, the transceiver 1801, theprocessor 1802, and the memory 1803 are connected to each other by usinga bus 1804. The bus 1804 may be a peripheral component interconnect(PCI) bus, an extended industry standard architecture (EISA) bus, or thelike. The bus may be classified into an address bus, a data bus, acontrol bus, and the like. For ease of representation, only one thickline is used to represent the bus in FIG. 18, but this does not meanthat there is only one bus or only one type of bus.

The transceiver 1801 is configured to: communicate and interact withanother device.

The processor 1802 is configured to implement the synchronization methodshown in FIG. 3. For details, refer to the related descriptions in theembodiment shown in FIG. 3. The details are not described herein again.

The memory 1803 is configured to store a program and the like. Forexample, the program may include program code, and the program codeincludes a computer operation instruction. The memory 1803 may include aRAM, and may further include a non-volatile memory, for example, atleast one magnetic disk storage. The processor 1802 performs theapplication program stored in the memory 1803, to implement theforegoing function, so as to implement the synchronization method shownin FIG. 3.

Based on the foregoing embodiments, an embodiment of this applicationfurther provides an access device. The access device is applied to thecommunications system shown in FIG. 1 or FIG. 2, and is configured toimplement the synchronization method shown in FIG. 3. Referring to FIG.19, the access device includes a transceiver 1901, a processor 1902, anda memory 1903.

The processor 1902 may be a CPU, an NP, a combination of a CPU and anNP, or the like. The processor 1902 may further include a hardware chip.The hardware chip may be an ASIC, a PLD, or a combination thereof. ThePLD may be a CPLD, an FPGA, a GAL, or any combination thereof. Theprocessor 1902 may implement the foregoing functions by hardware orcertainly by hardware executing corresponding software.

The transceiver 1901, the processor 1902, and the memory 1903 areconnected to each other. For example, the transceiver 1901, theprocessor 1902, and the memory 1903 are connected to each other by usinga bus 1904. The bus 1904 may be a peripheral component interconnect(PCI) bus, an extended industry standard architecture (EISA) bus, or thelike. The bus may be classified into an address bus, a data bus, acontrol bus, and the like. For ease of representation, only one thickline is used to represent the bus in FIG. 19, but this does not meanthat there is only one bus or only one type of bus.

The transceiver 1901 is configured to: communicate and interact withanother device.

The processor 1902 is configured to implement the synchronization methodshown in FIG. 3. For details, refer to the related descriptions in theembodiment shown in FIG. 3. The details are not described herein again.

The memory 1903 is configured to store a program and the like. Forexample, the program may include program code, and the program codeincludes a computer operation instruction. The memory 1903 may include aRAM, and may further include a non-volatile memory, for example, atleast one magnetic disk storage. The processor 1902 performs theapplication program stored in the memory 1903, to implement theforegoing function, so as to implement the synchronization method shownin FIG. 3.

Based on the foregoing embodiments, an embodiment of this applicationfurther provides a second device. The second device is applied to thecommunications system shown in FIG. 1 or FIG. 2, and is configured toimplement the synchronization method shown in FIG. 3. Referring to FIG.20, the second device includes a transceiver 2001, a processor 2002, anda memory 2003.

The processor 2002 may be a CPU, an NP, a combination of a CPU and anNP, or the like. The processor 2002 may further include a hardware chip.The hardware chip may be an ASIC, a PLD, or a combination thereof. ThePLD may be a CPLD, an FPGA, a GAL, or any combination thereof. Theprocessor 2002 may implement the foregoing functions by hardware orcertainly by hardware executing corresponding software.

The transceiver 2001, the processor 2002, and the memory 2003 areconnected to each other. For example, the transceiver 2001, theprocessor 2002, and the memory 2003 are connected to each other by usinga bus 2004. The bus 2004 may be a peripheral component interconnect(PCI) bus, an extended industry standard architecture (EISA) bus, or thelike. The bus may be classified into an address bus, a data bus, acontrol bus, and the like. For ease of representation, only one thickline is used to represent the bus in FIG. 20, but this does not meanthat there is only one bus or only one type of bus.

The transceiver 2001 is configured to: communicate and interact withanother device.

The processor 2002 is configured to implement the synchronization methodshown in FIG. 3. For details, refer to the related descriptions in theembodiment shown in FIG. 3. The details are not described herein again.

The memory 2003 is configured to store a program and the like. Forexample, the program may include program code, and the program codeincludes a computer operation instruction. The memory 2003 may include aRAM, and may further include a non-volatile memory, for example, atleast one magnetic disk storage. The processor 2002 performs theapplication program stored in the memory 2003, to implement theforegoing function, so as to implement the synchronization method shownin FIG. 3.

Based on the foregoing embodiments, an embodiment of this applicationfurther provides a first device. The first device is applied to thecommunications system shown in FIG. 1 or FIG. 2, and is configured toimplement the synchronization method shown in FIG. 7. Similarly,referring to FIG. 18, the first device includes a transceiver 1801, aprocessor 1802, and a memory 1803.

The processor 1802 may be a CPU, an NP, a combination of a CPU and anNP, or the like. The processor 1802 may further include a hardware chip.The hardware chip may be an ASIC, a PLD, or a combination thereof. ThePLD may be a CPLD, an FPGA, a GAL, or any combination thereof. Theprocessor 1802 may implement the foregoing functions by hardware orcertainly by hardware executing corresponding software.

The transceiver 1801, the processor 1802, and the memory 1803 areconnected to each other. For example, the transceiver 1801, theprocessor 1802, and the memory 1803 are connected to each other by usinga bus 1804. The bus 1804 may be a peripheral component interconnect(PCI) bus, an extended industry standard architecture (EISA) bus, or thelike. The bus may be classified into an address bus, a data bus, acontrol bus, and the like. For ease of representation, only one thickline is used to represent the bus in FIG. 18, but this does not meanthat there is only one bus or only one type of bus.

The transceiver 1801 is configured to: communicate and interact withanother device.

The processor 1802 is configured to implement the synchronization methodshown in FIG. 7. For details, refer to the related descriptions in theembodiment shown in FIG. 7. The details are not described herein again.

The memory 1803 is configured to store a program and the like. Forexample, the program may include program code, and the program codeincludes a computer operation instruction. The memory 1803 may include aRAM, and may further include a non-volatile memory, for example, atleast one magnetic disk storage. The processor 1802 performs theapplication program stored in the memory 1803, to implement theforegoing function, so as to implement the synchronization method shownin FIG. 7.

Based on the foregoing embodiments, an embodiment of this applicationfurther provides an access device. The access device is applied to thecommunications system shown in FIG. 1 or FIG. 2, and is configured toimplement the synchronization method shown in FIG. 7. Referring to FIG.19, the access device includes a transceiver 1901, a processor 1902, anda memory 1903.

The processor 1902 may be a CPU, an NP, a combination of a CPU and anNP, or the like. The processor 1902 may further include a hardware chip.The hardware chip may be an ASIC, a PLD, or a combination thereof. ThePLD may be a CPLD, an FPGA, a GAL, or any combination thereof. Theprocessor 1902 may implement the foregoing functions by hardware orcertainly by hardware executing corresponding software.

The transceiver 1901, the processor 1902, and the memory 1903 areconnected to each other. For example, the transceiver 1901, theprocessor 1902, and the memory 1903 are connected to each other by usinga bus 1904. The bus 1904 may be a peripheral component interconnect(PCI) bus, an extended industry standard architecture (EISA) bus, or thelike. The bus may be classified into an address bus, a data bus, acontrol bus, and the like. For ease of representation, only one thickline is used to represent the bus in FIG. 19, but this does not meanthat there is only one bus or only one type of bus.

The transceiver 1901 is configured to: communicate and interact withanother device.

The processor 1902 is configured to implement the synchronization methodshown in FIG. 7. For details, refer to the related descriptions in theembodiment shown in FIG. 7. The details are not described herein again.

The memory 1903 is configured to store a program and the like. Forexample, the program may include program code, and the program codeincludes a computer operation instruction. The memory 1903 may include aRAM, and may further include a non-volatile memory, for example, atleast one magnetic disk storage. The processor 1902 performs theapplication program stored in the memory 1903, to implement theforegoing function, so as to implement the synchronization method shownin FIG. 7.

Based on the foregoing embodiments, an embodiment of this applicationfurther provides a second device. The second device is applied to thecommunications system shown in FIG. 1 or FIG. 2, and is configured toimplement the synchronization method shown in FIG. 7. Referring to FIG.20, the second device includes a transceiver 2001, a processor 2002, anda memory 2003.

The processor 2002 may be a CPU, an NP, a combination of a CPU and anNP, or the like. The processor 2002 may further include a hardware chip.The hardware chip may be an ASIC, a PLD, or a combination thereof. ThePLD may be a CPLD, an FPGA, a GAL, or any combination thereof. Theprocessor 2002 may implement the foregoing functions by hardware orcertainly by hardware executing corresponding software.

The transceiver 2001, the processor 2002, and the memory 2003 areconnected to each other. For example, the transceiver 2001, theprocessor 2002, and the memory 2003 are connected to each other by usinga bus 2004. The bus 2004 may be a peripheral component interconnect(PCI) bus, an extended industry standard architecture (EISA) bus, or thelike. The bus may be classified into an address bus, a data bus, acontrol bus, and the like. For ease of representation, only one thickline is used to represent the bus in FIG. 20, but this does not meanthat there is only one bus or only one type of bus.

The transceiver 2001 is configured to: communicate and interact withanother device.

The processor 2002 is configured to implement the synchronization methodshown in FIG. 7. For details, refer to the related descriptions in theembodiment shown in FIG. 7. The details are not described herein again.

The memory 2003 is configured to store a program and the like. Forexample, the program may include program code, and the program codeincludes a computer operation instruction. The memory 2003 may include aRAM, and may further include a non-volatile memory, for example, atleast one magnetic disk storage. The processor 2002 performs theapplication program stored in the memory 2003, to implement theforegoing function, so as to implement the synchronization method shownin FIG. 7.

Based on the foregoing embodiments, an embodiment of this applicationfurther provides a first device. The first device is applied to thecommunications system shown in FIG. 1 or FIG. 2, and is configured toimplement the synchronization method shown in FIG. 8. Similarly,referring to FIG. 18, the first device includes a transceiver 1801, aprocessor 1802, and a memory 1803.

The processor 1802 may be a CPU, an NP, a combination of a CPU and anNP, or the like. The processor 1802 may further include a hardware chip.The hardware chip may be an ASIC, a PLD, or a combination thereof. ThePLD may be a CPLD, an FPGA, a GAL, or any combination thereof. Theprocessor 1802 may implement the foregoing functions by hardware orcertainly by hardware executing corresponding software.

The transceiver 1801, the processor 1802, and the memory 1803 areconnected to each other. For example, the transceiver 1801, theprocessor 1802, and the memory 1803 are connected to each other by usinga bus 1804. The bus 1804 may be a peripheral component interconnect(PCI) bus, an extended industry standard architecture (EISA) bus, or thelike. The bus may be classified into an address bus, a data bus, acontrol bus, and the like. For ease of representation, only one thickline is used to represent the bus in FIG. 18, but this does not meanthat there is only one bus or only one type of bus.

The transceiver 1801 is configured to: communicate and interact withanother device.

The processor 1802 is configured to implement the synchronization methodshown in FIG. 8. For details, refer to the related descriptions in theembodiment shown in FIG. 8. The details are not described herein again.

The memory 1803 is configured to store a program and the like. Forexample, the program may include program code, and the program codeincludes a computer operation instruction. The memory 1803 may include aRAM, and may further include a non-volatile memory, for example, atleast one magnetic disk storage. The processor 1802 performs theapplication program stored in the memory 1803, to implement theforegoing function, so as to implement the synchronization method shownin FIG. 8.

Based on the foregoing embodiments, an embodiment of this applicationfurther provides an access device. The access device is applied to thecommunications system shown in FIG. 1 or FIG. 2, and is configured toimplement the synchronization method shown in FIG. 8. Referring to FIG.19, the access device includes a transceiver 1901, a processor 1902, anda memory 1903.

The processor 1902 may be a CPU, an NP, a combination of a CPU and anNP, or the like. The processor 1902 may further include a hardware chip.The hardware chip may be an ASIC, a PLD, or a combination thereof. ThePLD may be a CPLD, an FPGA, a GAL, or any combination thereof. Theprocessor 1902 may implement the foregoing functions by hardware orcertainly by hardware executing corresponding software.

The transceiver 1901, the processor 1902, and the memory 1903 areconnected to each other. For example, the transceiver 1901, theprocessor 1902, and the memory 1903 are connected to each other by usinga bus 1904. The bus 1904 may be a peripheral component interconnect(PCI) bus, an extended industry standard architecture (EISA) bus, or thelike. The bus may be classified into an address bus, a data bus, acontrol bus, and the like. For ease of representation, only one thickline is used to represent the bus in FIG. 19, but this does not meanthat there is only one bus or only one type of bus.

The transceiver 1901 is configured to: communicate and interact withanother device.

The processor 1902 is configured to implement the synchronization methodshown in FIG. 8. For details, refer to the related descriptions in theembodiment shown in FIG. 8. The details are not described herein again.

The memory 1903 is configured to store a program and the like. Forexample, the program may include program code, and the program codeincludes a computer operation instruction. The memory 1903 may include aRAM, and may further include a non-volatile memory, for example, atleast one magnetic disk storage. The processor 1902 performs theapplication program stored in the memory 1903, to implement theforegoing function, so as to implement the synchronization method shownin FIG. 8.

Based on the foregoing embodiments, an embodiment of this applicationfurther provides a second device. The second device is applied to thecommunications system shown in FIG. 1 or FIG. 2, and is configured toimplement the synchronization method shown in FIG. 8. Referring to FIG.20, the second device includes a transceiver 2001, a processor 2002, anda memory 2003.

The processor 2002 may be a CPU, an NP, a combination of a CPU and anNP, or the like. The processor 2002 may further include a hardware chip.The hardware chip may be an ASIC, a PLD, or a combination thereof. ThePLD may be a CPLD, an FPGA, a GAL, or any combination thereof. Theprocessor 2002 may implement the foregoing functions by hardware orcertainly by hardware executing corresponding software.

The transceiver 2001, the processor 2002, and the memory 2003 areconnected to each other. For example, the transceiver 2001, theprocessor 2002, and the memory 2003 are connected to each other by usinga bus 2004. The bus 2004 may be a peripheral component interconnect(PCI) bus, an extended industry standard architecture (EISA) bus, or thelike. The bus may be classified into an address bus, a data bus, acontrol bus, and the like. For ease of representation, only one thickline is used to represent the bus in FIG. 20, but this does not meanthat there is only one bus or only one type of bus.

The transceiver 2001 is configured to: communicate and interact withanother device.

The processor 2002 is configured to implement the synchronization methodshown in FIG. 8. For details, refer to the related descriptions in theembodiment shown in FIG. 8. The details are not described herein again.

The memory 2003 is configured to store a program and the like. Forexample, the program may include program code, and the program codeincludes a computer operation instruction. The memory 2003 may include aRAM, and may further include a non-volatile memory, for example, atleast one magnetic disk storage. The processor 2002 performs theapplication program stored in the memory 2003, to implement theforegoing function, so as to implement the synchronization method shownin FIG. 8.

Based on the foregoing embodiments, an embodiment of this applicationfurther provides a first device. The first device is applied to thecommunications system shown in FIG. 1 or FIG. 2, and is configured toimplement the synchronization method shown in FIG. 10. Similarly,referring to FIG. 18, the first device includes a transceiver 1801, aprocessor 1802, and a memory 1803.

The processor 1802 may be a CPU, an NP, a combination of a CPU and anNP, or the like. The processor 1802 may further include a hardware chip.The hardware chip may be an ASIC, a PLD, or a combination thereof. ThePLD may be a CPLD, an FPGA, a GAL, or any combination thereof. Theprocessor 1802 may implement the foregoing functions by hardware orcertainly by hardware executing corresponding software.

The transceiver 1801, the processor 1802, and the memory 1803 areconnected to each other. For example, the transceiver 1801, theprocessor 1802, and the memory 1803 are connected to each other by usinga bus 1804. The bus 1804 may be a peripheral component interconnect(PCI) bus, an extended industry standard architecture (EISA) bus, or thelike. The bus may be classified into an address bus, a data bus, acontrol bus, and the like. For ease of representation, only one thickline is used to represent the bus in FIG. 18, but this does not meanthat there is only one bus or only one type of bus.

The transceiver 1801 is configured to: communicate and interact withanother device.

The processor 1802 is configured to implement the synchronization methodshown in FIG. 10. For details, refer to the related descriptions in theembodiment shown in FIG. 10. The details are not described herein again.

The memory 1803 is configured to store a program and the like. Forexample, the program may include program code, and the program codeincludes a computer operation instruction. The memory 1803 may include aRAM, and may further include a non-volatile memory, for example, atleast one magnetic disk storage. The processor 1802 performs theapplication program stored in the memory 1803, to implement theforegoing function, so as to implement the synchronization method shownin FIG. 10.

Based on the foregoing embodiments, an embodiment of this applicationfurther provides an access device. The access device is applied to thecommunications system shown in FIG. 1 or FIG. 2, and is configured toimplement the synchronization method shown in FIG. 10. Referring to FIG.19, the access device includes a transceiver 1901, a processor 1902, anda memory 1903.

The processor 1902 may be a CPU, an NP, a combination of a CPU and anNP, or the like. The processor 1902 may further include a hardware chip.The hardware chip may be an ASIC, a PLD, or a combination thereof. ThePLD may be a CPLD, an FPGA, a GAL, or any combination thereof. Theprocessor 1902 may implement the foregoing functions by hardware orcertainly by hardware executing corresponding software.

The transceiver 1901, the processor 1902, and the memory 1903 areconnected to each other. For example, the transceiver 1901, theprocessor 1902, and the memory 1903 are connected to each other by usinga bus 1904. The bus 1904 may be a peripheral component interconnect(PCI) bus, an extended industry standard architecture (EISA) bus, or thelike. The bus may be classified into an address bus, a data bus, acontrol bus, and the like. For ease of representation, only one thickline is used to represent the bus in FIG. 19, but this does not meanthat there is only one bus or only one type of bus.

The transceiver 1901 is configured to: communicate and interact withanother device.

The processor 1902 is configured to implement the synchronization methodshown in FIG. 10. For details, refer to the related descriptions in theembodiment shown in FIG. 10. The details are not described herein again.

The memory 1903 is configured to store a program and the like. Forexample, the program may include program code, and the program codeincludes a computer operation instruction. The memory 1903 may include aRAM, and may further include a non-volatile memory, for example, atleast one magnetic disk storage. The processor 1902 performs theapplication program stored in the memory 1903, to implement theforegoing function, so as to implement the synchronization method shownin FIG. 10.

Based on the foregoing embodiments, an embodiment of this applicationfurther provides a second device. The second device is applied to thecommunications system shown in FIG. 1 or FIG. 2, and is configured toimplement the synchronization method shown in FIG. 10. Referring to FIG.20, the second device includes a transceiver 2001, a processor 2002, anda memory 2003.

The processor 2002 may be a CPU, an NP, a combination of a CPU and anNP, or the like. The processor 2002 may further include a hardware chip.The hardware chip may be an ASIC, a PLD, or a combination thereof. ThePLD may be a CPLD, an FPGA, a GAL, or any combination thereof. Theprocessor 2002 may implement the foregoing functions by hardware orcertainly by hardware executing corresponding software.

The transceiver 2001, the processor 2002, and the memory 2003 areconnected to each other. For example, the transceiver 2001, theprocessor 2002, and the memory 2003 are connected to each other by usinga bus 2004. The bus 2004 may be a peripheral component interconnect(PCI) bus, an extended industry standard architecture (EISA) bus, or thelike. The bus may be classified into an address bus, a data bus, acontrol bus, and the like. For ease of representation, only one thickline is used to represent the bus in FIG. 20, but this does not meanthat there is only one bus or only one type of bus.

The transceiver 2001 is configured to: communicate and interact withanother device.

The processor 2002 is configured to implement the synchronization methodshown in FIG. 10. For details, refer to the related descriptions in theembodiment shown in FIG. 10. The details are not described herein again.

The memory 2003 is configured to store a program and the like. Forexample, the program may include program code, and the program codeincludes a computer operation instruction. The memory 2003 may include aRAM, and may further include a non-volatile memory, for example, atleast one magnetic disk storage. The processor 2002 performs theapplication program stored in the memory 2003, to implement theforegoing function, so as to implement the synchronization method shownin FIG. 10.

An embodiment of this application further provides anothersynchronization method, which is also applicable to the communicationssystems shown in FIG. 1 and FIG. 2. For example, in FIG. 21, a firstdevice is the UPF and a second device is the UE, or the first device isthe UE and the second device is the UPF. Referring to FIG. 21, aprocedure of the method includes the following operations.

Operation 2101: The first device sends a first packet to an accessdevice, and determines first timestamp information and second timestampinformation, where the first timestamp information is a moment that isin an Ethernet network and at which the first device sends the firstpacket, and the second timestamp information is a moment that is in amobile network and at which the first device sends the first packet.

A trigger condition for initiating a clock synchronization procedure bythe first device is the same as the principle described in operation 301in the embodiment shown in FIG. 3. For details, reference may be made toeach other. The details are not described herein again.

For example, FIG. 22 is a schematic diagram of packet receiving andsending in a process of performing synchronization between the firstdevice and the second device. In FIG. 22, a solid line indicates atransmission status of a packet in the Ethernet network, and a dashedline indicates a transmission status of a packet in the mobile network.It should be understood that in FIG. 22, a solid line and a dashed linethat are parallel in a same direction indicate transmission of a samepacket.

For example, in operation 2101, the moment corresponding to the firsttimestamp information is denoted as t9 in FIG. 22, and the momentcorresponding to the second timestamp information is denoted as t9′ inFIG. 22.

The first device is a user plane network element and the second deviceis a terminal device, or the first device is a terminal device and thesecond device is a user plane network element. In other words, either ofthe user plane network element and the terminal device may be a masterclock node, and the other needs to perform clock synchronization.

Operation 2102: The access device forwards the first packet to thesecond device.

Operation 2103: The second device determines fifth timestamp informationand sixth timestamp information, where the fifth timestamp informationis a moment that is in the Ethernet network and at which the seconddevice receives the first packet, and the sixth timestamp information isa moment that is in the mobile network and at which the second devicereceives the first packet.

For example, in FIG. 22, the moment corresponding to the fifth timestampinformation is denoted as t10, and the moment corresponding to the sixthtimestamp information is denoted as t10′.

Operation 2104: The first device sends a second packet to the accessdevice, where the second packet carries the first timestamp informationand the second timestamp information.

For example, the second packet may further carry a flag, and the flag isused to indicate that the second packet carries timestamp informationindicating a moment in the mobile network.

In an embodiment, a implementation in which the second packet carriesthe second timestamp information may be: The first device uses a firstprotocol field included in the second packet to carry the secondtimestamp information. For example, the first protocol field may be anexisting protocol field in the second packet in a current protocol stackframework. Alternatively, the first protocol field may be a protocolfield newly added to the second packet in a current protocol stackframework. For example, when the second packet further carries a flag,the flag may also be carried in the first protocol field.

For example, the first protocol field may be the same as the firstprotocol field in operation 701 in the embodiment shown in FIG. 7. Fordetailed descriptions of the first protocol field, refer to the relateddescriptions of the first protocol field in operation 701. No repeateddescription is provided herein.

Operation 2105: The access device sends a sixth packet to the seconddevice based on the second packet, where the sixth packet carries thefirst timestamp information and the second timestamp information.

In an embodiment, a method in which the access device sends the sixthpacket to the second device based on the second packet may be: Whendetecting that a first protocol field included in the second packetcarries the second timestamp information, the access device encapsulatesthe second timestamp information in a second protocol field in thesecond packet to generate the sixth packet, and sends the sixth packetto the second device. In this case, a second protocol field in the sixthpacket carries the second timestamp information.

For example, the first protocol field is the same as the first protocolfield in operation 2104. For details, also refer to the relateddescriptions in operation 701. The second protocol field may also be anexisting protocol field, or may be a newly added field in an existingprotocol stack framework. For example, an execution principle of sendingthe sixth packet by the access device to the second device based on thesecond packet is the same as the principle of sending the third packetby the access device to the second device based on the first packet inoperation 702 in the embodiment shown in FIG. 7. For details, refer tothe related principle in operation 702. The second protocol field may bethe same as the second protocol field in operation 702. For details,reference may be made to each other. The details are not describedherein again.

In an embodiment, after receiving the sixth packet from the accessdevice, the second device extracts the second timestamp informationcarried in the second protocol field included in the sixth packet. Forexample, for a method, refer to Cases n1, n2, and n3 in operation 702.Details are not described herein again.

Operation 2106: The second device sends a third packet to the accessdevice, and determines seventh timestamp information, where the seventhtimestamp information is a moment that is in the Ethernet network and atwhich the second device sends the third packet.

For example, in FIG. 22, the moment corresponding to the seventhtimestamp information is denoted as t11.

Operation 2107: The access device forwards the third packet to the firstdevice.

Operation 2108: The first device determines third timestamp information,where the third timestamp information is a moment that is in theEthernet network and at which the first device receives the thirdpacket.

For example, in FIG. 22, the moment corresponding to the third timestampinformation is denoted as t12.

Operation 2109: The first device sends a fourth packet to the accessdevice, and determines fourth timestamp information, where the fourthtimestamp information is a moment that is in the Ethernet network and atwhich the first device sends the fourth packet, and the fourth packetcarries the third timestamp information.

For example, in FIG. 22, the moment corresponding to the fourthtimestamp information is denoted as t13.

Operation 2110: The access device forwards the fourth packet to thesecond device.

Operation 2111: The second device determines eighth timestampinformation, where the eighth timestamp information is a moment that isin the Ethernet network and at which the second device receives thefourth packet.

For example, in FIG. 22, the moment corresponding to the eighthtimestamp information is denoted as t14.

Operation 2112: The first device sends a fifth packet to the accessdevice, where the fifth packet carries the fourth timestamp information.

Operation 2113: The access device forwards the fifth packet to thesecond device.

Operation 2114: The second device determines a time offset between thefirst device and the second device based on the first timestampinformation, the second timestamp information, the third timestampinformation, the fourth timestamp information, the fifth timestampinformation, the sixth timestamp information, the seventh timestampinformation, and the eighth timestamp information, and performs timesynchronization based on the time offset.

In an embodiment, a method in which the second device performs operation2114 may be:

The second device determines ninth timestamp information based on thesecond timestamp information (t9′), the third timestamp information(t12), the sixth timestamp information (t10′), the seventh timestampinformation (t11), and the eighth timestamp information (t14).

The second device deletes the fourth timestamp information (t13), anddetermines, based on the ninth timestamp information, the moment that isin the Ethernet network and at which the first device sends the fourthpacket to the access device.

The second device determines the time offset between the first deviceand the second device based on the first timestamp information (t9), thethird timestamp information (t12), the fifth timestamp information(t10), the seventh timestamp information (t11), the eighth timestampinformation (t14), and the ninth timestamp information.

For example, a time offset, namely, offset 3, between a master and aslaver (referred to as the first device and the second device herein) inan existing fixed network (the Ethernet network) may satisfy Formula 7:

$\begin{matrix}{{{offset}\; 3} = {{t\; 10} - {t\; 9} - \frac{{t\; 12} - {t\; 11} + {t\; 14}}{2} + {\frac{t}{2}.}}} & {{Formula}\mspace{14mu} 7}\end{matrix}$

Herein, t is the moment that is in the Ethernet network and at which thefirst device sends the fourth packet to the access device, and t is t13in the existing fixed network.

In this application, the time offset between the first device and thesecond device in a scenario in which the mobile network is connected tothe Ethernet network may be calculated through clock synchronizationbetween the first device and the second device that is implemented inthe mobile network. For example, the time offset may be obtained throughcalculation by using Formula 8 and Formula 9:t10−t9=offset4+delay3  Formula 8; andt10′−t9′=offset5+delay3  Formula 9.

Formula 8 indicates a time relationship in the Ethernet network, andoffset 4 is a time offset between the first device and the second devicein the Ethernet network. Formula 9 indicates a time relationship in themobile network, offset 5 is a time offset between the first device andthe second device in the mobile network, and delay 3 is a transmissiondelay from the first device to the second device.

Due to clock synchronization in the mobile network, a value of offset 5is 0. Therefore, it can be learned that delay 3=t10′−t9′, and it can befurther learned that offset 4=t10−t9−t10′+t9′. Then, assuming thatoffset 3=offset 4, the following may be obtained:

${{t\; 10} - {t\; 9} - {t\; 10^{\prime}} + {t\; 9^{\prime}}} = {{t\; 10} - {t\; 9} - \frac{{t\; 12} - {t\; 11} + {t\; 14}}{2} + \frac{t}{2}}$

Therefore, it can be learned through arrangement thatt=t12−t11+t14−2(t10′−t9′). In this case, obtained t is the ninthtimestamp information. In other words, a moment corresponding to theninth timestamp information is t12−t11+t14−2(t10′−t9′).

After obtaining the ninth timestamp information, the second device usesthe ninth timestamp information as the fourth timestamp information(t13) in the prior art for processing. For example, the second devicemay obtain a time offset between the first device and the second device.The time offset may satisfy Formula 10:

$\begin{matrix}{{{offset}\; 6} = {{t\; 10} - {t\; 9} - \frac{{t\; 12} - {t\; 11} + {t\; 14}}{2} + {\frac{{t\; 12} - {t\; 11} + {t\; 14} - {2\left( {{t\; 10^{\prime}} - {t\; 9^{\prime}}} \right)}}{2}.}}} & {{Formula}\mspace{14mu} 10}\end{matrix}$

It may be considered that Formula 10 is obtained after the second devicesubstitutes the ninth timestamp information into Formula 7 to replace t.In other words, Formula 10 is obtained after the second device uses theninth timestamp information as existing t13 for processing.

According to the synchronization method provided in an embodiment ofthis application, impact of a transmission delay between the firstdevice and the second device can be avoided, so that a time precisionrequirement of an industrial factory can be met in a scenario in whichthe mobile network is connected to the Ethernet network.

FIG. 23 is a schematic working diagram of another communications systemto which a synchronization method is applicable according to anembodiment of this application. A packet in FIG. 23 may be the same asthe packet in FIG. 2. For detailed descriptions, refer to the relateddescriptions in FIG. 2.

A master clock device in an Ethernet network is a PLC, and a masterclock in the Ethernet network is determined by the PLC. FIG. 23 shows amaster clock T1 in an Ethernet network synchronization domain. In theEthernet network synchronization domain, UE and a UPF are considered astwo adjacent nodes, and the UE and the UPF are a master and a slaver,namely, devices in a transmission path. During clock synchronization,the slaver needs to perform clock synchronization based on master clockinformation of the master.

In a mobile network synchronization domain, for a master clock device,refer to the related descriptions in FIG. 2. A master clock in themobile network is determined by the master clock device. FIG. 23 shows amaster clock T2 in the mobile network synchronization domain.Correspondingly, in the Ethernet network, there is another multi-hopdevice, for example, a RAN, between the UE and the UPF that are adjacentnodes. However, currently, clock synchronization in the mobile networkis implemented. Therefore, clock synchronization in the Ethernet networkcan be performed based on clock synchronization in the mobile network.

It should be noted that the UE in FIG. 23 is merely used as an exampleof a terminal device, or the UE may be replaced with another terminaldevice (for example, the mobile robot or the sensor 2 in FIG. 1). TheUPF is merely used as an example of a user plane network element, or theUPF may be replaced with another user plane network element. This is notlimited in this application.

An embodiment of this application further provides anothersynchronization method, which is applicable to the communicationssystems shown in FIG. 1 and FIG. 23. For example, in FIG. 24, a firstdevice is the UPF and a second device is the UE, or the first device isthe UE and the second device is the UPF. The third device is a master,and the fourth device is a slaver. Referring to FIG. 24, a procedure ofthe method includes the following operations.

Operation 2401: The first device receives a first packet from the thirddevice, and determines first timestamp information, where the firsttimestamp information is a moment that is in a mobile network and atwhich the first device receives the first packet.

For example, FIG. 25 is a schematic diagram of packet receiving andsending in a process of performing synchronization between the thirddevice and the fourth device.

For example, the moment corresponding to the first timestamp informationis denoted as t16 in FIG. 25.

The third device initiates a clock synchronization procedure. A triggercondition for initiating the clock synchronization procedure by thethird device is the same as the principle described in operation 301 inthe embodiment shown in FIG. 3. For details, reference may be made toeach other. The details are not described herein again.

Operation 2402: The first device sends the first packet to an accessdevice.

Operation 2403: The access device forwards the first packet to thesecond device.

The first device is a user plane network element and the second deviceis a terminal device, or the first device is a terminal device and thesecond device is a user plane network element.

Operation 2404: The second device sends the first packet to the fourthdevice, and determines fifth timestamp information, where the fifthtimestamp information is a moment that is in the mobile network and atwhich the second device sends the first packet to the fourth device.

For example, the moment corresponding to the fifth timestamp informationmay be denoted as t17 in FIG. 25.

Then, the fourth device determines a moment that is in an Ethernetnetwork and at which the fourth device receives the first packet sent bythe second device, for example, t18 shown in FIG. 25.

Operation 2405: The first device receives a second packet from the thirddevice.

The second packet carries a moment at which the third device sends thefirst packet, for example, t15 shown in FIG. 25.

Operation 2406: The first device sends a third packet to the accessdevice based on the second packet, where the third packet carries thefirst timestamp information, and the third packet further carries t15.

For example, the third packet may further carry a flag, and the flag isused to indicate that the third packet carries timestamp informationindicating a moment in the mobile network.

In an embodiment, a implementation in which the third packet carries thefirst timestamp information may be: The first device uses a firstprotocol field included in the third packet to carry the first timestampinformation. For example, the first protocol field may be an existingprotocol field in the third packet in a current protocol stackframework. Alternatively, the first protocol field may be a protocolfield newly added to the third packet in a current protocol stackframework. For example, when the third packet further carries a flag,the flag may also be carried in the first protocol field.

In an embodiment, the third packet may be generated by the first deviceby encapsulating the first timestamp information in a first protocolfield in the second packet.

For example, the first protocol field may be the same as the firstprotocol field in operation 701 in the embodiment shown in FIG. 7. Fordetailed descriptions of the first protocol field, refer to the relateddescriptions of the first protocol field in operation 701. No repeateddescription is provided herein.

Operation 2407: The access device sends a ninth packet to the seconddevice based on the third packet, where the ninth packet carries thefirst timestamp information.

For example, the ninth packet further carries t15.

In an embodiment, a method in which the access device sends the ninthpacket to the second device based on the third packet may be: Whendetecting that a first protocol field included in the third packetcarries the first timestamp information, the access device encapsulatesthe first timestamp information in a fourth protocol field in the thirdpacket to generate the ninth packet, and sends the ninth packet to thesecond device. In this case, a fourth protocol field in the ninth packetcarries the first timestamp information.

For example, the first protocol field is the same as the first protocolfield in operation 2406. For details, also refer to the relateddescriptions in operation 701. The fourth protocol field may also be anexisting protocol field, or may be a newly added field in an existingprotocol stack framework. For example, an execution principle of sendingthe ninth packet by the access device to the second device based on thethird packet is the same as the principle of sending the third packet bythe access device to the second device based on the first packet inoperation 702 in the embodiment shown in FIG. 7. For details, refer tothe related principle in operation 702. The fourth protocol field may bethe same as the second protocol field in operation 702. For details,reference may be made to each other. The details are not describedherein again.

In an embodiment, after receiving the ninth packet from the accessdevice, the second device extracts the first timestamp informationcarried in the fourth protocol field included in the ninth packet. Forexample, for a method, refer to Cases n1, n2, and n3 in operation 702.Details are not described herein again.

Operation 2408: The second device sends a twelfth packet to the fourthdevice based on the ninth packet.

In an implementation, when the second device performs operation 2408, amethod may be: The second device deletes the first timestamp informationfrom the fourth protocol field in the ninth packet to generate thetwelfth packet. In this case, the twelfth packet carries only t15.

Operation 2409: The second device receives a fourth packet from thefourth device, and determines sixth timestamp information, where thesixth timestamp information is a moment that is in the mobile networkand at which the second device receives the fourth packet.

The fourth device records a moment that is in the Ethernet network andat which the fourth device sends the fourth packet, for example, t19 inFIG. 25.

For example, the moment corresponding to the sixth timestamp informationis denoted as t20 in FIG. 25.

Operation 2410: The second device sends the fourth packet to the accessdevice.

Operation 2411: The access device sends the fourth packet to the firstdevice.

Operation 2412: The first device sends the fourth packet to the thirddevice, and determines second timestamp information, where the secondtimestamp information is a moment that is in the mobile network and atwhich the first device sends the fourth packet to the third device.

For example, the moment corresponding to the second timestampinformation is denoted as t21 in FIG. 25.

The third device records a moment that is in the Ethernet network and atwhich the third device receives the fourth packet, for example, t22shown in FIG. 25.

Operation 2413: The first device receives a fifth packet from the thirddevice, and determines third timestamp information, where the thirdtimestamp information is a moment that is in the mobile network and atwhich the first device receives the fifth packet.

The third device records a moment that is in the Ethernet network and atwhich the third device sends the fifth packet, for example, t23 in FIG.25.

For example, the moment corresponding to the third timestamp informationmay be denoted as t24 in FIG. 25.

Operation 2414: The first device sends a sixth packet to the accessdevice based on the fifth packet, where the sixth packet carries thesecond timestamp information.

The sixth packet further carries t22.

For example, the sixth packet may further carry a flag, and the flag isused to indicate that the sixth packet carries timestamp informationindicating a moment in the mobile network.

In an embodiment, a implementation in which the sixth packet carries thesecond timestamp information may be: The first device uses a secondprotocol field included in the sixth packet to carry the secondtimestamp information. For example, the second protocol field may be anexisting protocol field in the sixth packet in a current protocol stackframework. Alternatively, the second protocol field may be a protocolfield newly added to the sixth packet in a current protocol stackframework. For example, when the sixth packet further carries a flag,the flag may also be carried in the second protocol field.

In an embodiment, the sixth packet may be generated by the first deviceby encapsulating the second timestamp information in a second protocolfield in the fifth packet.

For example, the second protocol field may be the same as the firstprotocol field in operation 701 in the embodiment shown in FIG. 7. Fordetailed descriptions of the second protocol field, refer to the relateddescriptions of the first protocol field in operation 701. No repeateddescription is provided herein.

Operation 2415: The access device sends a tenth packet to the seconddevice based on the sixth packet, where the tenth packet carries thesecond timestamp information.

The tenth packet further carries t22.

In an embodiment, a method in which the access device sends the tenthpacket to the second device based on the sixth packet may be: whendetecting that a second protocol field included in the sixth packetcarries the second timestamp information, the access device encapsulatesthe second timestamp information in a fifth protocol field in the sixthpacket to generate the tenth packet, and sends the tenth packet to thesecond device. In this case, a fifth protocol field in the tenth packetcarries the second timestamp information.

For example, the second protocol field is the same as the secondprotocol field in operation 2414. For details, also refer to the relateddescriptions in operation 701. The fifth protocol field may also be anexisting protocol field, or may be a newly added field in an existingprotocol stack framework. For example, an execution principle of sendingthe tenth packet by the access device to the second device based on thesixth packet is the same as the principle of sending the third packet bythe access device to the second device based on the first packet inoperation 702 in the embodiment shown in FIG. 7. For details, refer tothe related principle in operation 702. The fifth protocol field may bethe same as the second protocol field in operation 702. For details,reference may be made to each other. The details are not describedherein again.

In an embodiment, after receiving the tenth packet from the accessdevice, the second device extracts the second timestamp informationcarried in the fifth protocol field included in the tenth packet. Forexample, for a method, refer to Cases n1, n2, and n3 in operation 702.Details are not described herein again.

Operation 2416: The second device sends a thirteenth packet to thefourth device, and determines seventh timestamp information, where theseventh timestamp information is a moment that is in the mobile networkand at which the second device sends the thirteenth packet to the fourthdevice.

The thirteenth packet is generated after the second device deletes thesecond timestamp information from the fifth protocol field in the tenthpacket. In this case, the thirteenth packet carries t22.

For example, the moment corresponding to the seventh timestampinformation may be denoted as t25 in FIG. 25.

In an embodiment, the fourth device records a moment that is in theEthernet network and at which the fourth device receives the thirteenthpacket, for example, t26 in FIG. 25.

Operation 2417: The first device receives a seventh packet from thethird device, where the seventh packet carries fourth timestampinformation, and the fourth timestamp information is a moment that is inthe Ethernet network and at which the third device sends the fifthpacket to the first device.

For example, the moment corresponding to the fourth timestampinformation is t23 in FIG. 25.

Operation 2418: The first device sends an eighth packet to the accessdevice, where the eighth packet carries the third timestamp informationand the fourth timestamp information.

For example, the eighth packet may further carry a flag, and the flag isused to indicate that the eighth packet carries timestamp informationindicating a moment in the mobile network.

In an embodiment, a method in which the eighth packet carries the thirdtimestamp information may be: The first device uses a third protocolfield included in the eighth packet to carry the third timestampinformation. For example, the third protocol field may be an existingprotocol field in the eighth packet in a current protocol stackframework. Alternatively, the third protocol field may be a protocolfield newly added to the eighth packet in a current protocol stackframework. For example, when the eighth packet further carries a flag,the flag may also be carried in the third protocol field.

In an embodiment, the eighth packet may be generated by the first deviceby encapsulating the third timestamp information in a third protocolfield in the seventh packet.

For example, the third protocol field may be the same as the firstprotocol field in operation 701 in the embodiment shown in FIG. 7. Fordetailed descriptions of the third protocol field, refer to the relateddescriptions of the first protocol field in operation 701. No repeateddescription is provided herein.

Operation 2419: The access device sends an eleventh packet to the seconddevice based on the eighth packet, where the eleventh packet carries thethird timestamp information and the fourth timestamp information.

In an embodiment, a method in which the access device sends the eleventhpacket to the second device based on the eighth packet may be: Whendetecting that a third protocol field included in the eighth packetcarries the third timestamp information, the access device encapsulatesthe third timestamp information in a sixth protocol field in the eighthpacket to generate the eleventh packet, and sends the eleventh packet tothe second device. In this case, a sixth protocol field in the eleventhpacket carries the second timestamp information.

For example, the third protocol field is the same as the third protocolfield in operation 2418. For details, also refer to the relateddescriptions in operation 701. The sixth protocol field may also be anexisting protocol field, or may be a newly added field in an existingprotocol stack framework. For example, an execution principle of sendingthe eleventh packet by the access device to the second device based onthe eighth packet is the same as the principle of sending the thirdpacket by the access device to the second device based on the firstpacket in operation 702 in the embodiment shown in FIG. 7. For details,refer to the related principle in operation 702. The sixth protocolfield may be the same as the second protocol field in operation 702. Fordetails, reference may be made to each other. The details are notdescribed herein again.

In an embodiment, after receiving the eleventh packet from the accessdevice, the second device extracts the third timestamp informationcarried in the sixth protocol field included in the eleventh packet. Forexample, for a method, refer to Cases n1, n2, and n3 in operation 702.Details are not described herein again.

Operation 2420: The second device determines eighth timestampinformation based on the first timestamp information (t16), the secondtimestamp information (t21), the third timestamp information (t24), thefourth timestamp information, the fifth timestamp information (t17), thesixth timestamp information (t20), and the seventh timestamp information(t25).

For example, a time offset, namely, offset 7, between the master and theslaver (referred to as the third device and the fourth device herein) inan existing fixed network (the Ethernet network) may satisfy Formula 11:

$\begin{matrix}{{{offset}\; 7} = {{t\; 18} - {t\; 15} - \frac{{t\; 22} - {t\; 19} + {t\; 26}}{2} + {\frac{t^{\prime}}{2}.}}} & {{Formula}\mspace{14mu} 11}\end{matrix}$

Herein, t′ is the moment that is in the Ethernet network and at whichthe third device sends the fifth packet to the access device, and t′ ist23 in the existing fixed network.

For example, a time relationship in the Ethernet network represents thatcases in Formula 12 to Formula 14 may exist:t18−t15=offset8+delay4+Δt1+Δt2  Formula 12;t22−t19=−offset8+delay5+Δt1+Δt2  Formula 13; andt26−t23=offset8+delay6+Δt1+Δt2  Formula 14.

Herein, offset 8 is a time offset between the third device and thefourth device in the Ethernet network, delay 4 is a transmission delayfrom the first device to the second device, delay 5 is a transmissiondelay from the second device to the first device, delay 6 is atransmission delay from the first device to the second device, Δt1 istransmission duration between the third device and the first device (ortransmission duration between the second device and the fourth device),and Δt2 is transmission duration between the second device and thefourth device (or transmission duration between the third device and thefirst device).

A time relationship in the mobile network represents that cases inFormula 15 to Formula 17 may exist:t17−t16=offset9+delay4  Formula 15;t21−t20=−offset9+delay5  Formula 16; andt25−t24=offset9+delay6  Formula 17.

Herein, offset 9 is a time offset between the first device and thesecond device in the mobile network.

Due to clock synchronization in the mobile network, a value of offset 9is 0. Therefore, it can be learned that delay 4=t17−t16.

It can be learned through arrangement by using Formula 13, Formula 14,Formula 16, and Formula 17 thatΔt1+Δt2=[t22−t19+t26−t23−(t21−t20+t25−t24)]/2.

The following may be obtained by substituting delay 4 and a result ofΔt1+Δt2 into Formula 12.

${{offset}\; 8} = {{t\; 18} - {t\; 15} - \frac{{t\; 22} - {t\; 19} + {t\; 26}}{2} + \frac{t\; 23}{2} + \frac{{t\; 21} - {t\; 20} + {t\; 25} - {t\; 24}}{2} + {t\; 16} - {t\; 17.}}$

Assuming that offset 8=offset 7, the following may be obtained:

${{t\; 18} - {t\; 15} - \frac{{t\; 22} - {t\; 19} + {t\; 26}}{2} + \frac{t\; 23}{2} + \frac{{t\; 21} - {t\; 20} + {t\; 25} - {t\; 24}}{2} + {t\; 16} - {t\; 17}} = {{t\; 18} - {t\; 15} - \frac{{t\; 22} - {t\; 19} + {t\; 26}}{2} + {\frac{t^{\prime}}{2}.}}$

Then, it can be learned through arrangement thatt=2(t16−t17)+t23+t21−t20+t25−t24. In this case, obtained t′ is theeighth timestamp information. In other words, a moment corresponding tothe eighth timestamp information is 2(t16−t17)+t23+t21−t20+t25−t24.

Operation 2421: The second device sends the eighth timestamp informationto the fourth device, so that the fourth device performs timesynchronization based on the eighth timestamp information.

In the prior art, the second device sends t23 to the fourth device. Inthis application, the second device sends the eighth timestampinformation to the fourth device by using an existing method for sendingt23. It may also be understood that the eighth timestamp information issent to the fourth device in place of t23. In this way, when receivingthe eighth timestamp information, the fourth device uses the eighthtimestamp information as t23 in the prior art for processing.

In an embodiment, after receiving the eighth timestamp information, thefourth device obtains a time offset between the third device and thefourth device based on t18, t15, t22, t19, t26, and the eighth timestampinformation (2(t16−t17)+t23+t21−t20+t25−t24). The time offset maysatisfy Formula 18:

$\begin{matrix}{{{offset}\; 10} = {{t\; 18} - {t\; 15} - \frac{{t\; 22} - {t\; 19} + {t\; 26}}{2} + {\frac{{2\left( {{t\; 16} - {t\; 17}} \right)} + {t\; 23} + {t\; 21} - {t\; 20} + {t\; 25} - {t\; 24}}{2}.}}} & {{Formula}\mspace{14mu} 18}\end{matrix}$

It may be considered that Formula 18 is obtained after the fourth devicesubstitutes the eighth timestamp information into Formula 11 to replacet′. In other words, Formula 18 is obtained after the fourth device usesthe eighth timestamp information as existing t23 for processing.

Based on the foregoing result, the fourth device may perform timesynchronization based on offset 10.

According to the synchronization method provided in an embodiment ofthis application, impact of a transmission delay between the firstdevice and the second device can be avoided, so that a time precisionrequirement of an industrial factory can be met in a scenario in whichthe mobile network is connected to the Ethernet network.

An embodiment of this application further provides anothersynchronization method, which is applicable to the communicationssystems shown in FIG. 1 and FIG. 23. For example, in FIG. 26, a firstdevice is the UPF and a second device is the UE, or the first device isthe UE and the second device is the UPF. The third device is a master,and the fourth device is a slaver. Referring to FIG. 26, a procedure ofthe method includes the following operations.

Operation 2601: The first device receives a first packet from the thirddevice, and determines first timestamp information, where the firsttimestamp information is a moment that is in a mobile network and atwhich the first device receives the first packet.

For example, FIG. 27 is a schematic diagram of packet receiving andsending in a process of performing synchronization between the thirddevice and the fourth device.

For example, the moment corresponding to the first timestamp informationmay be t28 shown in FIG. 27.

In an embodiment, the first packet carries a moment that is in anEthernet network and at which the third device sends the first packet,for example, t27 shown in FIG. 27.

The third device initiates a clock synchronization procedure. A triggercondition for initiating the clock synchronization procedure by thethird device is the same as the principle described in operation 301 inthe embodiment shown in FIG. 3. For details, reference may be made toeach other. The details are not described herein again.

Operation 2602: The first device sends the first packet to the accessdevice.

Operation 2603: The access device sends the first packet to the seconddevice.

The first device is a user plane network element and the second deviceis a terminal device, or the first device is a terminal device and thesecond device is a user plane network element.

Operation 2604: The second device sends the first packet to the fourthdevice, and determines second timestamp information, where the secondtimestamp information is a moment that is in the mobile network and atwhich the second device sends the first packet.

For example, the moment corresponding to the second timestampinformation may be t29 in FIG. 27.

After receiving the first packet, the fourth device records a momentthat is in the Ethernet network and at which the fourth device receivesthe first packet, for example, t30 in FIG. 27.

Operation 2605: The second device receives a fifth packet from thefourth device, and determines third timestamp information, where thethird timestamp information is a moment that is in the mobile networkand at which the second device receives the fifth packet.

For example, the moment corresponding to the third timestamp informationmay be denoted as t32 in FIG. 27.

The fourth device may record a moment that is in the Ethernet networkand at which the fourth device sends the fifth packet, for example, t31shown in FIG. 27.

Operation 2606: The second device sends a fourth packet to the accessdevice, where the fourth packet carries the second timestamp informationand the third timestamp information.

For example, the fourth packet may further carry a flag, and the flag isused to indicate that the fourth packet carries timestamp informationindicating a moment in the mobile network.

In an embodiment, a method in which the fourth packet carries the secondtimestamp information and the third timestamp information may be: Thesecond device uses a second protocol field included in the fourth packetto carry the second timestamp information and the third timestampinformation. For example, the second protocol field may be an existingprotocol field in the fourth packet in a current protocol stackframework. Alternatively, the second protocol field may be a protocolfield newly added to the fourth packet in a current protocol stackframework. For example, when the fourth packet further carries a flag,the flag may also be carried in the second protocol field.

In an embodiment, the fourth packet may be generated by the seconddevice by encapsulating the second timestamp information and the thirdtimestamp information in a second protocol field in the fifth packet.

For example, the second protocol field may be the same as the secondprotocol field in operation 304 in the embodiment shown in FIG. 3. Fordetailed descriptions of the second protocol field, refer to the relateddescriptions of the second protocol field in operation 304. No repeateddescription is provided herein.

Operation 2607: The access device sends a second packet to the firstdevice, where the second packet carries the second timestamp informationand the third timestamp information.

In an embodiment, a method in which the access device sends the secondpacket to the first device may be: When detecting that a second protocolfield included in the fourth packet carries the second timestampinformation and the third timestamp information, the access deviceencapsulates the second timestamp information and the third timestampinformation in a first protocol field included in the fourth packet togenerate the second packet, and sends the second packet to the firstdevice.

For example, the second protocol field is the same as the secondprotocol field in operation 2606. For details, also refer to the relateddescriptions in operation 304. The first protocol field may also be anexisting protocol field, or may be a newly added field in an existingprotocol stack framework. For example, an execution principle of sendingthe second packet by the access device to the first device is the sameas the principle of sending the second packet by the access device tothe first device in operation 306 in the embodiment shown in FIG. 3. Fordetails, refer to the related principle in operation 306. The firstprotocol field may be the same as the first protocol field in operation306. For details, reference may be made to each other. The details arenot described herein again.

In an embodiment, after receiving the second packet from the accessdevice, the first device extracts the second timestamp information andthe third timestamp information that are carried in a first protocolfield included in the second packet. For example, for a method, refer toCases g1, g2, and g3 in operation 306. Details are not described hereinagain.

Operation 2608: The first device sends a third packet to the thirddevice.

In an implementation, when the first device performs operation 2608, amethod may be: The first device deletes the second timestamp informationand the third timestamp information from the first protocol field in thesecond packet to generate the third packet, and sends the third packet.

The third device may record a moment that is in the Ethernet network andat which the third device receives the third packet, for example, t34 inFIG. 27.

Operation 2609: The first device determines fourth timestampinformation, where the fourth timestamp information is a moment that isin the mobile network and at which the first device sends the thirdpacket.

For example, the moment corresponding to the fourth timestampinformation may be denoted as t33 in FIG. 27.

Operation 2610: The first device receives a sixth packet from the thirddevice, where the sixth packet carries fifth timestamp information, andthe fifth timestamp information is a moment that is in the Ethernetnetwork and at which the third device receives the third packet sent bythe first device.

The moment corresponding to the fifth timestamp information is t34 inFIG. 27.

Operation 2611: The first device determines sixth timestamp informationbased on the first timestamp information, the second timestampinformation, the third timestamp information, the fourth timestampinformation, and the fifth timestamp information.

In an embodiment, a method in which the first device performs operation2611 may be: The first device determines a round-trip transmission delaydifference between the first device and the second device based on thefirst timestamp information (t28), the second timestamp information(t29), the third timestamp information (t32), and the fourth timestampinformation (t33). Then, the first device calculates a sum of the moment(t34) corresponding to the fifth timestamp information and theround-trip transmission delay difference, to obtain the sixth timestampinformation.

For example, the round-trip transmission delay difference between thefirst device and the second device may be calculated through clocksynchronization between the first device and the second device that isimplemented in the mobile network. For example, the round-triptransmission delay difference may be obtained through calculation byusing Formula 19 and Formula 20:t29−t28=delay7+offset10  Formula 19; andt33−t32=delay8−offset10  Formula 20.

In the foregoing formulas, offset 10 is a time offset between the firstdevice and the second device in the mobile network, delay 7 is atransmission delay from the first device to the second device, and delay8 is a transmission delay from the second device to the first device.

Due to clock synchronization in the mobile network, a value of offset 10is 0. Therefore, the round-trip transmission delay difference may beobtained by using Formula 19 and Formula 20, that is, delay 7−delay8=t29−t28−t33+t32.

Further, a moment corresponding to the sixth timestamp information ist34+t29−t28−t33+t32.

Operation 2612: The first device sends the sixth timestamp informationto the access device.

For example, in the prior art, the first device sends the fifthtimestamp information to the access device, so that the access devicesends the fifth timestamp information to the second device, andtransmits the fifth timestamp information to the fourth device. In thisapplication, the first device transmits the sixth timestamp informationto the fourth device by using an existing method for sending the fifthtimestamp information. It may also be understood that the sixthtimestamp information is sent to the fourth device in place of the fifthtimestamp information. In this way, when receiving the sixth timestampinformation, the fourth device uses the sixth timestamp information asthe fifth timestamp information in the prior art for processing.

In an embodiment, when the first device performs operation 2612, thefirst device may replace the fifth timestamp information in the sixthpacket with the sixth timestamp information to generate a seventhpacket, and send the seventh packet to the access device, where theseventh packet carries the sixth timestamp information, and finally, theseventh packet is sent to the fourth device.

Operation 2613: The access device sends the sixth timestamp informationto the second device.

Operation 2614: The second device sends the sixth timestamp informationto the fourth device, so that the fourth device performs timesynchronization based on the sixth timestamp information.

In an embodiment, the fourth device may determine a time offset betweenthe third device and the fourth device based on t27, t30, t31, and thesixth timestamp information (t34+t29−t28−t33+t32), and perform timesynchronization based on the time offset.

In an embodiment, as described in operation 2612, the fourth device maydetermine, based on the sixth timestamp information, the moment that isin the Ethernet network, at which the third device receives the thirdpacket, and that is considered by the fourth device, and use the sixthtimestamp information as the fifth timestamp information.

For example, a time offset, namely, offset 11, between the third deviceand the fourth device may satisfy Formula 21:

$\begin{matrix}{{{offset}\; 11} = {\frac{{t\; 30} - {t\; 27} - \left( {{t\; 34} + {t\; 29} - {t\; 28} - {t\; 33} + {t\; 32}} \right) + {t\; 31}}{2}.}} & {{Formula}\mspace{14mu} 21}\end{matrix}$

According to the synchronization method provided in an embodiment ofthis application, impact of a transmission delay between the firstdevice and the second device can be avoided, so that a time precisionrequirement of an industrial factory can be met in a scenario in whichthe mobile network is connected to the Ethernet network.

An embodiment of this application further provides anothersynchronization method, which is applicable to the communicationssystems shown in FIG. 1 and FIG. 23. For example, in FIG. 28, a firstdevice is the UPF and a second device is the UE, or the first device isthe UE and the second device is the UPF. The third device is a master,and the fourth device is a slaver. Referring to FIG. 28, a procedure ofthe method includes the following operations.

Operation 2801: The first device receives a first packet from the thirddevice, and determines first timestamp information, where the firsttimestamp information is a moment that is in a mobile network and atwhich the first device receives the first packet.

A trigger condition for initiating a clock synchronization procedure bythe third device is the same as the principle described in operation 301in the embodiment shown in FIG. 3. For details, reference may be made toeach other. The details are not described herein again.

For example, FIG. 29 is a schematic diagram of packet receiving andsending in a process of performing synchronization between the thirddevice and the fourth device.

For example, the first timestamp information may be denoted as t36 inFIG. 29.

In an embodiment, the first packet carries a moment that is in anEthernet network and at which the third device sends the first packet,for example, t35 shown in FIG. 29.

Operation 2802: The first device sends a second packet to an accessdevice based on the first packet, where the second packet carries thefirst timestamp information.

In an embodiment, a method in which the second packet carries the firsttimestamp information may be: The first device uses a first protocolfield included in the second packet to carry the first timestampinformation. For example, the first protocol field may be an existingprotocol field in the second packet in a current protocol stackframework. Alternatively, the first protocol field may be a protocolfield newly added to the second packet in a current protocol stackframework. For example, when the second packet further carries a flag,the flag may also be carried in the first protocol field.

In an embodiment, the second packet may be generated by the first deviceby encapsulating the first timestamp information in a third protocolfield in the first packet.

For example, the first protocol field may be the same as the firstprotocol field in operation 701 in the embodiment shown in FIG. 7. Fordetailed descriptions of the first protocol field, refer to the relateddescriptions of the first protocol field in operation 701. No repeateddescription is provided herein.

In an embodiment, the second packet further carries t35.

Operation 2803: The access device sends a fifth packet to the seconddevice based on the second packet, where the fifth packet carries thefirst timestamp information.

The first device is a user plane network element and the second deviceis a terminal device, or the first device is a terminal device and thesecond device is a user plane network element.

In an embodiment, a method in which the access device sends the fifthpacket to the second device based on the second packet may be: When theaccess device detects that a first protocol field included in the secondpacket includes the first timestamp information, the access deviceencapsulates the first timestamp information in a second protocol fieldincluded in the second packet to generate the fifth packet, and sendsthe fifth packet to the second device. In this case, a second protocolfield in the fifth packet carries the first timestamp information.

For example, the first protocol field is the same as the first protocolfield in operation 2802. For details, also refer to the relateddescriptions in operation 701. The second protocol field may also be anexisting protocol field, or may be a newly added field in an existingprotocol stack framework. For example, an execution principle of sendingthe fifth packet by the access device to the second device based on thesecond packet is the same as the principle of sending the third packetby the access device to the second device based on the first packet inoperation 702 in the embodiment shown in FIG. 7. For details, refer tothe related principle in operation 702. The second protocol field may bethe same as the second protocol field in operation 702. For details,reference may be made to each other. The details are not describedherein again.

In an embodiment, after receiving the fifth packet from the accessdevice, the second device extracts the first timestamp informationcarried in the second protocol field included in the fifth packet. Forexample, for a method, refer to Cases n1, n2, and n3 in operation 702.Details are not described herein again.

The fifth packet further carries t35.

Operation 2804: The second device sends a sixth packet to the fourthdevice, and determines fourth timestamp information, where the fourthtimestamp information is a moment that is in the mobile network and atwhich the second device sends the sixth packet.

For example, the fourth timestamp information may be denoted as t37 inFIG. 29.

The sixth packet may be generated after the second device deletes thefirst timestamp information from the second protocol field in the fifthpacket. In this case, the sixth packet carries t35.

In an embodiment, the fourth device records a moment that is in theEthernet network and at which the fourth device receives the sixthpacket, for example, t38 in FIG. 29.

Operation 2805: The second device receives a third packet from thefourth device, and determines fifth timestamp information, where thefifth timestamp information is a moment that is in the mobile networkand at which the second device receives the third packet.

For example, the fifth timestamp information may be denoted as t40 inFIG. 29.

In an embodiment, the fourth device records a moment that is in theEthernet network and at which the fourth device sends the third packet,for example, t39 in FIG. 29.

Operation 2806: The second device sends the third packet to the accessdevice.

Operation 2807. The access device sends the third packet to the firstdevice.

Operation 2808: The first device sends the third packet to the thirddevice, and determines second timestamp information, where the secondtimestamp information is a moment that is in the mobile network and atwhich the first device sends the third packet.

For example, the moment corresponding to the second timestampinformation may be denoted as t41 in FIG. 29.

In an embodiment, the third device records a moment that is in theEthernet network and at which the third device receives the thirdpacket, for example, t42 shown in FIG. 29.

Operation 2809: The first device receives a fourth packet from the thirddevice, where the fourth packet carries third timestamp information, andthe third timestamp information is a moment that is in the Ethernetnetwork and at which the third device receives the third packet sent bythe first device.

The moment corresponding to the third timestamp information is t42.

Operation 2810: The first device sends the second timestamp informationand the third timestamp information to the access device.

Operation 2811. The access device sends the second timestamp informationand the third timestamp information to the second device.

Operation 2812: The second device determines sixth timestamp informationbased on the first timestamp information, the second timestampinformation, the third timestamp information, the fourth timestampinformation, and the fifth timestamp information.

In an embodiment, a method in which the second device performs operation2812 may be: The second device determines a round-trip transmissiondelay difference between the first device and the second device based onthe first timestamp information (t36), the second timestamp information(t41), the fourth timestamp information (t37), and the fifth timestampinformation (t40). The second device calculates a sum of the momentcorresponding to the third timestamp information and the round-triptransmission delay difference, to obtain the sixth timestampinformation.

For example, the round-trip transmission delay difference between thefirst device and the second device may be calculated through clocksynchronization between the first device and the second device that isimplemented in the mobile network. For example, the round-triptransmission delay difference may be obtained through calculation byusing Formula 22 and Formula 23:t37−t36=delay9+offset12  Formula 22; andt41−t40=delay10−offset12  Formula 23.

In the foregoing formulas, offset 12 is a time offset between the firstdevice and the second device in the mobile network, delay 9 is atransmission delay from the first device to the second device, and delay10 is a transmission delay from the second device to the first device.

Due to clock synchronization in the mobile network, a value of offset 12is 0. Therefore, the round-trip transmission delay difference may beobtained by using Formula 22 and Formula 23, that is, delay 9−delay10=t37−t36−t41+t40.

Further, a moment corresponding to the sixth timestamp information ist42+t37−t36−t41+t40.

Operation 2813: The second device sends the sixth timestamp informationto the fourth device, so that the fourth device performs timesynchronization based on the sixth timestamp information.

For example, in the prior art, the second device sends the fourthtimestamp information to the fourth device. In this application, thesecond device sends the sixth timestamp information to the fourth deviceby using an existing method for sending the fourth timestampinformation. It may also be understood that the sixth timestampinformation is sent to the fourth device in place of the fourthtimestamp information. In this way, when receiving the sixth timestampinformation, the fourth device uses the sixth timestamp information asthe fourth timestamp information in the prior art for processing.

In an embodiment, the fourth device may determine a time offset betweenthe third device and the fourth device based on t35, t38, t39, and thesixth timestamp information (t42+t37−t36−t41+t40), and perform timesynchronization based on the time offset.

In an embodiment, the fourth device may determine, based on the sixthtimestamp information, the moment that is in the Ethernet network, atwhich the third device receives the third packet, and that is consideredby the fourth device, and use the sixth timestamp information as thefourth timestamp information.

For example, a time offset, namely, offset 13, between the third deviceand the fourth device may satisfy Formula 24:

$\begin{matrix}{{{offset}\; 13} = {\frac{{t\; 38} - {t\; 35} - \left( {{t\; 42} + {t\; 37} - {t\; 36} - {t\; 41} + {t\; 40}} \right) + {t\; 39}}{2}.}} & {{Formula}\mspace{14mu} 24}\end{matrix}$

According to the synchronization method provided an this embodiment ofthis application, impact of a transmission delay between the firstdevice and the second device can be avoided, so that a time precisionrequirement of an industrial factory can be met in a scenario in whichthe mobile network is connected to the Ethernet network.

Based on the foregoing embodiments, this application further provides afirst device. The first device may be applied to the communicationssystem shown in FIG. 1 or FIG. 2, and is configured to implement thesynchronization method provided in the embodiment shown in FIG. 21. Fora structure of the first device, also refer to FIG. 11. The first devicemay include a receiving unit 1103, a processing unit 1102, and a sendingunit 1101.

The receiving unit 1103 is configured to receive a first packet from athird device. The processing unit 1102 is configured to determine firsttimestamp information, where the first timestamp information is a momentthat is in a mobile network and at which the first device receives thefirst packet. The sending unit 1101 is configured to send the firstpacket to a second device by using an access device. The receiving unit1103 is further configured to receive a second packet from the thirddevice. The sending unit 1101 is further configured to send a thirdpacket to the access device based on the second packet, where the thirdpacket carries the first timestamp information. The receiving unit 1103is further configured to receive a fourth packet from the access device.The sending unit 1101 is further configured to send the fourth packet tothe third device. The processing unit 1102 is further configured todetermine second timestamp information, where the second timestampinformation is a moment that is in the mobile network and at which thefirst device sends the fourth packet to the third device. The receivingunit 1103 is further configured to receive a fifth packet from the thirddevice. The processing unit 1102 is further configured to determinethird timestamp information, where the third timestamp information is amoment that is in the mobile network and at which the first devicereceives the fifth packet. The sending unit 1101 is further configuredto send a sixth packet to the access device based on the fifth packet,where the sixth packet carries the second timestamp information. Thereceiving unit 1103 is further configured to receive a seventh packetfrom the third device, where the seventh packet carries fourth timestampinformation, and the fourth timestamp information is a moment that is inan Ethernet network and at which the third device sends the fifth packetto the first device. The sending unit 1101 is further configured to sendan eighth packet to the access device, where the eighth packet carriesthe third timestamp information and the fourth timestamp information.The first device is a user plane network element and the second deviceis a terminal device, or the first device is a terminal device and thesecond device is a user plane network element.

In addition, another operation or function of the first device in themethod in the embodiment shown in FIG. 21 may be further implementedbased on the receiving unit 1103, the processing unit 1102, and thesending unit 1101 in the first device. For details, refer to theforegoing embodiments. The details are not described herein again.

Based on the foregoing embodiments, this application further provides anaccess device. The access device may be applied to the communicationssystem shown in FIG. 1 or FIG. 2, and is configured to implement thesynchronization method provided in the embodiment shown in FIG. 21. Fora structure of the access device, also refer to FIG. 12. The accessdevice may include a receiving unit 1201 and a sending unit 1202.

The receiving unit 1201 is configured to receive a first packet from thefirst device. The sending unit 1202 is configured to forward the firstpacket to a second device. The receiving unit 1201 is further configuredto receive a third packet from the first device, where the third packetcarries first timestamp information, and the first timestamp informationis a moment that is in a mobile network and at which the first devicereceives the first packet from a third device. The sending unit 1202 isfurther configured to send a ninth packet to the second device based onthe third packet, where the ninth packet carries the first timestampinformation. The receiving unit 1201 is further configured to receive afourth packet from the second device. The sending unit 1202 is furtherconfigured to send the fourth packet to the first device. The receivingunit 1201 is further configured to receive a sixth packet from the firstdevice, where the sixth packet is sent by the first device to the accessdevice based on a fifth packet after the first device receives the fifthpacket from the third device, the sixth packet carries second timestampinformation, and the second timestamp information is a moment that is inthe mobile network and at which the first device sends the fourth packetto the third device after receiving the fourth packet from the accessdevice. The sending unit 1202 is further configured to send a tenthpacket to the second device based on the sixth packet, where the tenthpacket carries the second timestamp information. The receiving unit 1201is further configured to receive an eighth packet from the first device,where the eighth packet carries third timestamp information and fourthtimestamp information, the third timestamp information is a moment thatis in the mobile network and at which the first device receives thefifth packet from the third device, and the fourth timestamp informationis a moment that is in an Ethernet network and at which the third devicesends the fifth packet to the first device. The sending unit 1202 isfurther configured to send an eleventh packet to the second device basedon the eighth packet, where the eleventh packet carries the thirdtimestamp information and the fourth timestamp information. The firstdevice is a user plane network element and the second device is aterminal device, or the first device is a terminal device and the seconddevice is a user plane network element.

For example, the access device may further include a processing unit,configured to detect timestamp information in a protocol field in apacket. For an operation, refer to an operation of the access device inthe embodiment shown in FIG. 21. Details are not described herein again.

In addition, another operation or function of the access device in themethod in the embodiment shown in FIG. 21 may be further implementedbased on the receiving unit 1201 and the sending unit 1202, or theprocessing unit in the access device. For details, refer to theforegoing embodiments. The details are not described herein again.

Based on the foregoing embodiments, this application further provides asecond device. The second device may be applied to the communicationssystem shown in FIG. 1 or FIG. 2, and is configured to implement thesynchronization method provided in the embodiment shown in FIG. 21. Fora structure of the second device, also refer to FIG. 13. The seconddevice may include a receiving unit 1301, a processing unit 1302, and asending unit 1303.

The receiving unit 1301 is configured to receive a first packet from anaccess device. The sending unit 1303 is configured to send the firstpacket to a fourth device. The processing unit 1302 is configured todetermine fifth timestamp information, where the fifth timestampinformation is a moment that is in a mobile network and at which thesecond device sends the first packet to the fourth device. The receivingunit 1301 is further configured to receive a ninth packet from theaccess device, where the ninth packet carries first timestampinformation, and the first timestamp information is a moment that is inthe mobile network and at which the first device receives the firstpacket from a third device. The sending unit 1303 is further configuredto send a twelfth packet to the fourth device based on the ninth packet.The receiving unit 1301 is further configured to receive a fourth packetfrom the fourth device. The processing unit 1302 is further configuredto determine sixth timestamp information, where the sixth timestampinformation is a moment that is in the mobile network and at which thesecond device receives the fourth packet. The sending unit 1303 isfurther configured to send the fourth packet to the access device. Thereceiving unit 1301 is further configured to receive a tenth packet fromthe access device, where the tenth packet carries second timestampinformation, and the second timestamp information is a moment that is inthe mobile network and at which the first device sends the fourth packetto the third device after the access device sends the fourth packet tothe first device. The sending unit 1303 is further configured to send athirteenth packet to the fourth device. The processing unit 1302 isfurther configured to determine seventh timestamp information, where theseventh timestamp information is a moment that is in the mobile networkand at which the second device sends the thirteenth packet to the fourthdevice. The receiving unit 1301 is further configured to receive aneleventh packet from the access device, where the eleventh packetcarries third timestamp information and fourth timestamp information,the third timestamp information is a moment that is in the mobilenetwork and at which the first device receives the fifth packet from thethird device, and the fourth timestamp information is a moment that isin an Ethernet network and at which the third device sends the fifthpacket to the first device. The processing unit 1302 is furtherconfigured to determine eighth timestamp information based on the firsttimestamp information, the second timestamp information, the thirdtimestamp information, the fourth timestamp information, the fifthtimestamp information, the sixth timestamp information, and the seventhtimestamp information. The sending unit 1303 is further configured tosend the eighth timestamp information to the fourth device, so that thefourth device performs time synchronization based on the eighthtimestamp information. The first device is a user plane network elementand the second device is a terminal device, or the first device is aterminal device and the second device is a user plane network element.

In addition, another operation or function of the second device in themethod in the embodiment shown in FIG. 21 may be further implementedbased on the receiving unit 1301, the processing unit 1302, and thesending unit 1303 in the second device. For details, refer to theforegoing embodiments. The details are not described herein again.

Based on the foregoing embodiments, this application further provides afirst device. The first device may be applied to the communicationssystem shown in FIG. 1 or FIG. 23, and is configured to implement thesynchronization method provided in the embodiment shown in FIG. 24. Fora structure of the first device, also refer to FIG. 11. The first devicemay include a sending unit 1101, a processing unit 1102, and a receivingunit 1103.

The sending unit 1101 is configured to send a first packet to an accessdevice. The processing unit 1102 is configured to determine firsttimestamp information and second timestamp information, where the firsttimestamp information is a moment that is in an Ethernet network and atwhich the first device sends the first packet, and the second timestampinformation is a moment that is in a mobile network and at which thefirst device sends the first packet. The sending unit 1101 is furtherconfigured to send a second packet to the access device, where thesecond packet carries the first timestamp information and the secondtimestamp information. The receiving unit 1103 is configured to receivea third packet from the access device. The processing unit 1102 isfurther configured to determine third timestamp information, where thethird timestamp information is a moment that is in the Ethernet networkand at which the first device receives the third packet. The sendingunit 1101 is further configured to send a fourth packet to the accessdevice, where the fourth packet carries the third timestamp information.The processing unit 1102 is further configured to determine fourthtimestamp information, where the fourth timestamp information is amoment that is in the Ethernet network and at which the first devicesends the fourth packet. The sending unit 1101 is further configured tosend a fifth packet to the access device, where the fifth packet carriesthe fourth timestamp information. The first device is a user planenetwork element and the second device is a terminal device, or the firstdevice is a terminal device and the second device is a user planenetwork element.

In addition, another operation or function of the first device in themethod in the embodiment shown in FIG. 24 may be further implementedbased on the receiving unit 1103, the processing unit 1102, and thesending unit 1101 in the first device. For details, refer to theforegoing embodiments. The details are not described herein again.

Based on the foregoing embodiments, this application further provides anaccess device. The access device may be applied to the communicationssystem shown in FIG. 1 or FIG. 23, and is configured to implement thesynchronization method provided in the embodiment shown in FIG. 24. Fora structure of the access device, also refer to FIG. 12. The accessdevice may include a receiving unit 1201 and a sending unit 1202.

The receiving unit 1201 is configured to receive a first packet from afirst device. The sending unit 1202 is configured to forward the firstpacket to a second device. The receiving unit 1201 is further configuredto receive a second packet from the first device, where the secondpacket carries first timestamp information and second timestampinformation, the first timestamp information is a moment that is in anEthernet network and at which the first device sends the first packet tothe access device, and the second timestamp information is a moment thatis in a mobile network and at which the first device sends the firstpacket to the access device. The sending unit 1202 is further configuredto send a sixth packet to the second device based on the second packet,where the sixth packet carries the first timestamp information and thesecond timestamp information. The receiving unit 1201 is furtherconfigured to receive a third packet from the second device. The sendingunit 1202 is further configured to forward the third packet to the firstdevice. The receiving unit 1201 is further configured to receive afourth packet from the first device, where the fourth packet carriesthird timestamp information, and the third timestamp information is amoment that is in the Ethernet network and at which the first devicereceives the third packet sent by the access device. The sending unit1202 is further configured to forward the fourth packet to the seconddevice. The receiving unit 1201 is further configured to receive a fifthpacket from the first device, where the fifth packet carries fourthtimestamp information, and the fourth timestamp information is a momentthat is in the Ethernet network and at which the first device sends thefourth packet to the access device. The sending unit 1202 is furtherconfigured to forward the fifth packet to the second device. The firstdevice is a user plane network element and the second device is aterminal device, or the first device is a terminal device and the seconddevice is a user plane network element.

For example, the access device may further include a processing unit,configured to detect timestamp information in a protocol field in apacket. For an operation, refer to an operation of the access device inthe embodiment shown in FIG. 24. Details are not described herein again.

In addition, another operation or function of the access device in themethod in the embodiment shown in FIG. 24 may be further implementedbased on the receiving unit 1201 and the sending unit 1202, or theprocessing unit in the access device. For details, refer to theforegoing embodiments. The details are not described herein again.

Based on the foregoing embodiments, this application further provides asecond device. The second device may be applied to the communicationssystem shown in FIG. 1 or FIG. 23, and is configured to implement thesynchronization method provided in the embodiment shown in FIG. 24. Fora structure of the second device, also refer to FIG. 13. The seconddevice may include a receiving unit 1301, a processing unit 1302, and asending unit 1303.

The receiving unit 1301 is configured to receive a first packet from anaccess device. The processing unit 1302 is configured to determine fifthtimestamp information and sixth timestamp information, where the fifthtimestamp information is a moment that is in an Ethernet network and atwhich the second device receives the first packet, and the sixthtimestamp information is a moment that is in a mobile network and atwhich the second device receives the first packet. The receiving unit1301 is further configured to receive a sixth packet from the accessdevice, where the sixth packet carries first timestamp information andthe second timestamp information, the first timestamp information is amoment that is in the Ethernet network and at which the first devicesends the first packet to the access device, and the second timestampinformation is a moment that is in the mobile network and at which thefirst device sends the first packet to the access device. The sendingunit 1303 is configured to send a third packet to the access device. Theprocessing unit 1302 is further configured to determine seventhtimestamp information, where the seventh timestamp information is amoment that is in the Ethernet network and at which the second devicesends the third packet. The receiving unit 1301 is further configured toreceive a fourth packet from the access device, where the fourth packetcarries third timestamp information, and the third timestamp informationis a moment that is in the Ethernet network and at which the firstdevice receives the third packet after the access device receives thethird packet from the second device and forwards the third packet to thefirst device. The processing unit 1302 is further configured todetermine eighth timestamp information, where the eighth timestampinformation is a moment that is in the Ethernet network and at which thesecond device receives the fourth packet. The receiving unit 1301 isfurther configured to receive a fifth packet from the access device,where the fifth packet carries fourth timestamp information, and thefourth timestamp information is a moment that is in the Ethernet networkand at which the first device sends the fourth packet to the accessdevice. The processing unit 1302 is further configured to: determine atime offset between the first device and the second device based on thefirst timestamp information, the second timestamp information, the thirdtimestamp information, the fourth timestamp information, the fifthtimestamp information, the sixth timestamp information, the seventhtimestamp information, and the eighth timestamp information, and performtime synchronization based on the time offset. The first device is auser plane network element and the second device is a terminal device,or the first device is a terminal device and the second device is a userplane network element.

In addition, another operation or function of the second device in themethod in the embodiment shown in FIG. 24 may be further implementedbased on the receiving unit 1301, the processing unit 1302, and thesending unit 1303 in the second device. For details, refer to theforegoing embodiments. The details are not described herein again.

Based on the foregoing embodiments, this application further provides afirst device. The first device may be applied to the communicationssystem shown in FIG. 1 or FIG. 23, and is configured to implement thesynchronization method provided in the embodiment shown in FIG. 26. Fora structure of the first device, also refer to FIG. 11. The first devicemay include a sending unit 1101, a processing unit 1102, and a receivingunit 1103.

The receiving unit 1103 is configured to receive a first packet from athird device. The sending unit 1101 is configured to send the firstpacket to a second device by using an access device. The processing unit1102 is configured to determine first timestamp information, where thefirst timestamp information is a moment that is in a mobile network andat which the first device receives the first packet. The receiving unit1103 is further configured to receive a second packet from the accessdevice, where the second packet carries second timestamp information andthird timestamp information, the second timestamp information is amoment that is in the mobile network and at which the second devicesends the first packet to a fourth device after receiving the firstpacket, and the third timestamp information is a moment that is in themobile network and at which the second device receives a fifth packetfrom the fourth device. The sending unit 1101 is further configured tosend a third packet to the third device. The processing unit 1102 isfurther configured to determine fourth timestamp information, where thefourth timestamp information is a moment that is in the mobile networkand at which the first device sends the third packet. The receiving unit1103 is further configured to receive a sixth packet from the thirddevice, where the sixth packet carries fifth timestamp information, andthe fifth timestamp information is a moment that is in an Ethernetnetwork and at which the third device receives the third packet sent bythe first device. The processing unit 1102 is further configured todetermine sixth timestamp information based on the first timestampinformation, the second timestamp information, the third timestampinformation, the fourth timestamp information, and the fifth timestampinformation. The sending unit 1101 is further configured to forward thesixth timestamp information to the second device by using the accessdevice. The first device is a user plane network element and the seconddevice is a terminal device, or the first device is a terminal deviceand the second device is a user plane network element.

In addition, another operation or function of the first device in themethod in the embodiment shown in FIG. 26 may be further implementedbased on the receiving unit 1103, the processing unit 1102, and thesending unit 1101 in the first device. For details, refer to theforegoing embodiments. The details are not described herein again.

Based on the foregoing embodiments, this application further provides anaccess device. The access device may be applied to the communicationssystem shown in FIG. 1 or FIG. 23, and is configured to implement thesynchronization method provided in the embodiment shown in FIG. 26. Fora structure of the access device, also refer to FIG. 12. The accessdevice may include a receiving unit 1201 and a sending unit 1202.

The receiving unit 1201 is configured to receive a first packet from thefirst device. The sending unit 1202 is configured to send the firstpacket to a second device. The receiving unit 1201 is further configuredto receive a fourth packet from the second device, where the fourthpacket carries second timestamp information and third timestampinformation, the second timestamp information is a moment that is in themobile network and at which the second device sends the first packet toa fourth device after receiving the first packet, the fourth packet issent by the second device to the access device based on a fifth packetafter the second device receives the fifth packet from the fourthdevice, and the third timestamp information is a moment that is in themobile network and at which the second device receives the fifth packet.The sending unit 1202 is further configured to send a second packet tothe first device, where the second packet carries the second timestampinformation and the third timestamp information. The receiving unit 1201is further configured to receive sixth timestamp information from thefirst device. The sending unit 1202 is further configured to send thesixth timestamp information to the second device. The first device is auser plane network element and the second device is a terminal device,or the first device is a terminal device and the second device is a userplane network element.

For example, the access device may further include a processing unit,configured to detect timestamp information in a protocol field in apacket. For an operation, refer to an operation of the access device inthe embodiment shown in FIG. 26. Details are not described herein again.

In addition, another operation or function of the access device in themethod in the embodiment shown in FIG. 26 may be further implementedbased on the receiving unit 1201 and the sending unit 1202, or theprocessing unit in the access device. For details, refer to theforegoing embodiments. The details are not described herein again.

Based on the foregoing embodiments, this application further provides asecond device. The second device may be applied to the communicationssystem shown in FIG. 1 or FIG. 23, and is configured to implement thesynchronization method provided in the embodiment shown in FIG. 26. Fora structure of the second device, also refer to FIG. 13. The seconddevice may include a receiving unit 1301, a processing unit 1302, and asending unit 1303.

The receiving unit 1301 is configured to receive a first packet from anaccess device. The sending unit 1303 is configured to send the firstpacket to a fourth device. The processing unit 1302 is configured todetermine second timestamp information, where the second timestampinformation is a moment that is in a mobile network and at which thesecond device sends the first packet. The receiving unit 1301 is furtherconfigured to receive a fifth packet from the fourth device. Theprocessing unit 1302 is further configured to determine third timestampinformation, where the third timestamp information is a moment that isin the mobile network and at which the second device receives the fifthpacket. The sending unit 1303 is further configured to send a fourthpacket to the access device, where the fourth packet carries the secondtimestamp information and the third timestamp information. The receivingunit 1301 is further configured to receive sixth timestamp informationfrom the access device. The sending unit 1303 is further configured tosend the sixth timestamp information to the fourth device, so that thefourth device performs time synchronization based on the sixth timestampinformation. The first device is a user plane network element and thesecond device is a terminal device, or the first device is a terminaldevice and the second device is a user plane network element.

In addition, another operation or function of the second device in themethod in the embodiment shown in FIG. 26 may be further implementedbased on the receiving unit 1301, the processing unit 1302, and thesending unit 1303 in the second device. For details, refer to theforegoing embodiments. The details are not described herein again.

Based on the foregoing embodiments, this application further provides afirst device. The first device may be applied to the communicationssystem shown in FIG. 1 or FIG. 23, and is configured to implement thesynchronization method provided in the embodiment shown in FIG. 28. Fora structure of the first device, also refer to FIG. 11. The first devicemay include a sending unit 1101, a processing unit 1102, and a receivingunit 1103.

The receiving unit 1103 is configured to receive a first packet from athird device. The processing unit 1102 is configured to determine firsttimestamp information, where the first timestamp information is a momentthat is in a mobile network and at which the first device receives thefirst packet. The sending unit 1101 is configured to send a secondpacket to an access device based on the first packet, where the secondpacket carries the first timestamp information. The receiving unit 1103is further configured to receive a third packet from the access device.The sending unit 1101 is further configured to send the third packet tothe third device. The processing unit 1102 is configured to determinesecond timestamp information, where the second timestamp information isa moment that is in the mobile network and at which the first devicesends the third packet. The receiving unit 1103 is further configured toreceive a fourth packet from the third device, where the fourth packetcarries third timestamp information, and the third timestamp informationis a moment that is in an Ethernet network and at which the third devicereceives the third packet sent by the first device. The sending unit1101 is further configured to send the second timestamp information andthe third timestamp information to the access device. The first deviceis a user plane network element and the second device is a terminaldevice, or the first device is a terminal device and the second deviceis a user plane network element.

In addition, another operation or function of the first device in themethod in the embodiment shown in FIG. 28 may be further implementedbased on the receiving unit 1103, the processing unit 1102, and thesending unit 1101 in the first device. For details, refer to theforegoing embodiments. The details are not described herein again.

Based on the foregoing embodiments, this application further provides anaccess device. The access device may be applied to the communicationssystem shown in FIG. 1 or FIG. 23, and is configured to implement thesynchronization method provided in the embodiment shown in FIG. 28. Fora structure of the access device, also refer to FIG. 12. The accessdevice may include a receiving unit 1201 and a sending unit 1202.

The receiving unit 1201 is configured to receive a second packet fromthe first device, where the second packet carries first timestampinformation, the second packet is sent by the first device to the accessdevice after the first device receives a first packet from a thirddevice, and the first timestamp information is a moment that is in amobile network and at which the first device receives the first packet.The sending unit 1202 is configured to send a fifth packet to a seconddevice based on the second packet, where the fifth packet carries thefirst timestamp information.

The receiving unit 1201 is further configured to receive a third packetfrom the second device. The sending unit 1202 is further configured tosend the third packet to the first device. The receiving unit 1201 isfurther configured to receive second timestamp information and thirdtimestamp information from the first device, where the second timestampinformation is a moment that is in the mobile network and at which thefirst device sends the third packet to the third device after receivingthe third packet, and the third timestamp information is a moment thatis in an Ethernet network and at which the third device receives thethird packet sent by the first device. The sending unit 1202 is furtherconfigured to send the second timestamp information and the thirdtimestamp information to the second device. The first device is a userplane network element and the second device is a terminal device, or thefirst device is a terminal device and the second device is a user planenetwork element.

For example, the access device may further include a processing unit,configured to detect timestamp information in a protocol field in apacket. For an operation, refer to an operation of the access device inthe embodiment shown in FIG. 28. Details are not described herein again.

In addition, another operation or function of the access device in themethod in the embodiment shown in FIG. 28 may be further implementedbased on the receiving unit 1201 and the sending unit 1202, or theprocessing unit in the access device. For details, refer to theforegoing embodiments. The details are not described herein again.

Based on the foregoing embodiments, this application further provides asecond device. The second device may be applied to the communicationssystem shown in FIG. 1 or FIG. 23, and is configured to implement thesynchronization method provided in the embodiment shown in FIG. 28. Fora structure of the second device, also refer to FIG. 13. The seconddevice may include a receiving unit 1301, a processing unit 1302, and asending unit 1303.

The receiving unit 1301 is configured to receive a fifth packet from anaccess device, where the fifth packet carries first timestampinformation, and the first timestamp information is a moment that is ina mobile network and at which a first device receives a first packetfrom a third device. The sending unit 1303 is configured to send a sixthpacket to a fourth device. The processing unit 1302 is configured todetermine fourth timestamp information, where the fourth timestampinformation is a moment that is in the mobile network and at which thesecond device sends the sixth packet. The receiving unit 1301 is furtherconfigured to receive a third packet from the fourth device. Theprocessing unit 1302 is further configured to determine fifth timestampinformation, where the fifth timestamp information is a moment that isin the mobile network and at which the second device receives the thirdpacket. The sending unit 1303 is further configured to send the thirdpacket to the access device. The receiving unit 1301 is furtherconfigured to receive second timestamp information and third timestampinformation from the access device, where the second timestampinformation is a moment that is in the mobile network and at which thefirst device sends the third packet to the third device after the accessdevice receives the third packet and sends the third packet to the firstdevice, and the third timestamp information is a moment that is in anEthernet network and at which the third device receives the third packetsent by the first device. The processing unit 1302 is further configuredto determine sixth timestamp information based on the first timestampinformation, the second timestamp information, the third timestampinformation, the fourth timestamp information, and the fifth timestampinformation. The sending unit 1303 is further configured to send thesixth timestamp information to the fourth device, so that the fourthdevice performs time synchronization based on the sixth timestampinformation. The first device is a user plane network element and thesecond device is a terminal device, or the first device is a terminaldevice and the second device is a user plane network element.

In addition, another operation or function of the second device in themethod in the embodiment shown in FIG. 28 may be further implementedbased on the receiving unit 1301, the processing unit 1302, and thesending unit 1303 in the second device. For details, refer to theforegoing embodiments. The details are not described herein again.

Based on the foregoing embodiments, an embodiment of this applicationfurther provides a first device. The first device is applied to thecommunications system shown in FIG. 1 or FIG. 2, and is configured toimplement the synchronization method shown in FIG. 21. Similarly,referring to FIG. 18, the first device includes a transceiver 1801, aprocessor 1802, and a memory 1803.

The processor 1802 may be a CPU, an NP, a combination of a CPU and anNP, or the like. The processor 1802 may further include a hardware chip.The hardware chip may be an ASIC, a PLD, or a combination thereof. ThePLD may be a CPLD, an FPGA, a GAL, or any combination thereof. Theprocessor 1802 may implement the foregoing functions by hardware orcertainly by hardware executing corresponding software.

The transceiver 1801, the processor 1802, and the memory 1803 areconnected to each other. For example, the transceiver 1801, theprocessor 1802, and the memory 1803 are connected to each other by usinga bus 1804. The bus 1804 may be a peripheral component interconnect(PCI) bus, an extended industry standard architecture (EISA) bus, or thelike. The bus may be classified into an address bus, a data bus, acontrol bus, and the like. For ease of representation, only one thickline is used to represent the bus in FIG. 18, but this does not meanthat there is only one bus or only one type of bus.

The transceiver 1801 is configured to: communicate and interact withanother device.

The processor 1802 is configured to implement the synchronization methodshown in FIG. 21. For details, refer to the related descriptions in theembodiment shown in FIG. 21. The details are not described herein again.

The memory 1803 is configured to store a program and the like. Forexample, the program may include program code, and the program codeincludes a computer operation instruction. The memory 1803 may include aRAM, and may further include a non-volatile memory, for example, atleast one magnetic disk storage. The processor 1802 performs theapplication program stored in the memory 1803, to implement theforegoing function, so as to implement the synchronization method shownin FIG. 21.

Based on the foregoing embodiments, an embodiment of this applicationfurther provides an access device. The access device is applied to thecommunications system shown in FIG. 1 or FIG. 2, and is configured toimplement the synchronization method shown in FIG. 21. Referring to FIG.19, the access device includes a transceiver 1901, a processor 1902, anda memory 1903.

The processor 1902 may be a CPU, an NP, a combination of a CPU and anNP, or the like. The processor 1902 may further include a hardware chip.The hardware chip may be an ASIC, a PLD, or a combination thereof. ThePLD may be a CPLD, an FPGA, a GAL, or any combination thereof. Theprocessor 1902 may implement the foregoing functions by hardware orcertainly by hardware executing corresponding software.

The transceiver 1901, the processor 1902, and the memory 1903 areconnected to each other. For example, the transceiver 1901, theprocessor 1902, and the memory 1903 are connected to each other by usinga bus 1904. The bus 1904 may be a peripheral component interconnect(PCI) bus, an extended industry standard architecture (EISA) bus, or thelike. The bus may be classified into an address bus, a data bus, acontrol bus, and the like. For ease of representation, only one thickline is used to represent the bus in FIG. 19, but this does not meanthat there is only one bus or only one type of bus.

The transceiver 1901 is configured to: communicate and interact withanother device.

The processor 1902 is configured to implement the synchronization methodshown in FIG. 21. For details, refer to the related descriptions in theembodiment shown in FIG. 21. The details are not described herein again.

The memory 1903 is configured to store a program and the like. Forexample, the program may include program code, and the program codeincludes a computer operation instruction. The memory 1903 may include aRAM, and may further include a non-volatile memory, for example, atleast one magnetic disk storage. The processor 1902 performs theapplication program stored in the memory 1903, to implement theforegoing function, so as to implement the synchronization method shownin FIG. 21.

Based on the foregoing embodiments, an embodiment of this applicationfurther provides a second device. The second device is applied to thecommunications system shown in FIG. 1 or FIG. 2, and is configured toimplement the synchronization method shown in FIG. 21. Referring to FIG.20, the second device includes a transceiver 2001, a processor 2002, anda memory 2003.

The processor 2002 may be a CPU, an NP, a combination of a CPU and anNP, or the like. The processor 2002 may further include a hardware chip.The hardware chip may be an ASIC, a PLD, or a combination thereof. ThePLD may be a CPLD, an FPGA, a GAL, or any combination thereof. Theprocessor 2002 may implement the foregoing functions by hardware orcertainly by hardware executing corresponding software.

The transceiver 2001, the processor 2002, and the memory 2003 areconnected to each other. For example, the transceiver 2001, theprocessor 2002, and the memory 2003 are connected to each other by usinga bus 2004. The bus 2004 may be a peripheral component interconnect(PCI) bus, an extended industry standard architecture (EISA) bus, or thelike. The bus may be classified into an address bus, a data bus, acontrol bus, and the like. For ease of representation, only one thickline is used to represent the bus in FIG. 20, but this does not meanthat there is only one bus or only one type of bus.

The transceiver 2001 is configured to: communicate and interact withanother device.

The processor 2002 is configured to implement the synchronization methodshown in FIG. 21. For details, refer to the related descriptions in theembodiment shown in FIG. 21. The details are not described herein again.

The memory 2003 is configured to store a program and the like. Forexample, the program may include program code, and the program codeincludes a computer operation instruction. The memory 2003 may include aRAM, and may further include a non-volatile memory, for example, atleast one magnetic disk storage. The processor 2002 performs theapplication program stored in the memory 2003, to implement theforegoing function, so as to implement the synchronization method shownin FIG. 21.

Based on the foregoing embodiments, an embodiment of this applicationfurther provides a first device. The first device is applied to thecommunications system shown in FIG. 1 or FIG. 23, and may be configuredto implement the synchronization method shown in FIG. 24, FIG. 26, orFIG. 28. Similarly, referring to FIG. 18, the first device includes atransceiver 1801, a processor 1802, and a memory 1803.

The processor 1802 may be a CPU, an NP, a combination of a CPU and anNP, or the like. The processor 1802 may further include a hardware chip.The hardware chip may be an ASIC, a PLD, or a combination thereof. ThePLD may be a CPLD, an FPGA, a GAL, or any combination thereof. Theprocessor 1802 may implement the foregoing functions by hardware orcertainly by hardware executing corresponding software.

The transceiver 1801, the processor 1802, and the memory 1803 areconnected to each other. For example, the transceiver 1801, theprocessor 1802, and the memory 1803 are connected to each other by usinga bus 1804. The bus 1804 may be a peripheral component interconnect(PCI) bus, an extended industry standard architecture (EISA) bus, or thelike. The bus may be classified into an address bus, a data bus, acontrol bus, and the like. For ease of representation, only one thickline is used to represent the bus in FIG. 18, but this does not meanthat there is only one bus or only one type of bus.

The transceiver 1801 is configured to: communicate and interact withanother device.

The processor 1802 is configured to implement the synchronization methodshown in FIG. 24, FIG. 26, or FIG. 28. For details, refer to the relateddescriptions in the embodiment shown in FIG. 24, FIG. 26, or FIG. 28.The details are not described herein again.

The memory 1803 is configured to store a program and the like. Forexample, the program may include program code, and the program codeincludes a computer operation instruction. The memory 1803 may include aRAM, and may further include a non-volatile memory, for example, atleast one magnetic disk storage. The processor 1802 performs theapplication program stored in the memory 1803, to implement theforegoing function, so as to implement the synchronization method shownin FIG. 24, FIG. 26, or FIG. 28.

Based on the foregoing embodiments, an embodiment of this applicationfurther provides an access device. The access device is applied to thecommunications system shown in FIG. 1 or FIG. 2, and is configured toimplement the synchronization method shown in FIG. 24, FIG. 26, or FIG.28. Referring to FIG. 19, the access device includes a transceiver 1901,a processor 1902, and a memory 1903.

The processor 1902 may be a CPU, an NP, a combination of a CPU and anNP, or the like. The processor 1902 may further include a hardware chip.The hardware chip may be an ASIC, a PLD, or a combination thereof. ThePLD may be a CPLD, an FPGA, a GAL, or any combination thereof. Theprocessor 1902 may implement the foregoing functions by hardware orcertainly by hardware executing corresponding software.

The transceiver 1901, the processor 1902, and the memory 1903 areconnected to each other. For example, the transceiver 1901, theprocessor 1902, and the memory 1903 are connected to each other by usinga bus 1904. The bus 1904 may be a peripheral component interconnect(PCI) bus, an extended industry standard architecture (EISA) bus, or thelike. The bus may be classified into an address bus, a data bus, acontrol bus, and the like. For ease of representation, only one thickline is used to represent the bus in FIG. 19, but this does not meanthat there is only one bus or only one type of bus.

The transceiver 1901 is configured to: communicate and interact withanother device.

The processor 1902 is configured to implement the synchronization methodshown in FIG. 24, FIG. 26, or FIG. 28. For details, refer to the relateddescriptions in the embodiment shown in FIG. 24, FIG. 26, or FIG. 28.The details are not described herein again.

The memory 1903 is configured to store a program and the like. Forexample, the program may include program code, and the program codeincludes a computer operation instruction. The memory 1903 may include aRAM, and may further include a non-volatile memory, for example, atleast one magnetic disk storage. The processor 1902 performs theapplication program stored in the memory 1903, to implement theforegoing function, so as to implement the synchronization method shownin FIG. 24, FIG. 26, or FIG. 28.

Based on the foregoing embodiments, an embodiment of this applicationfurther provides a second device. The second device is applied to thecommunications system shown in FIG. 1 or FIG. 2, and is configured toimplement the synchronization method shown in FIG. 24, FIG. 26, or FIG.28. Referring to FIG. 20, the second device includes a transceiver 2001,a processor 2002, and a memory 2003.

The processor 2002 may be a CPU, an NP, a combination of a CPU and anNP, or the like. The processor 2002 may further include a hardware chip.The hardware chip may be an ASIC, a PLD, or a combination thereof. ThePLD may be a CPLD, an FPGA, a GAL, or any combination thereof. Theprocessor 2002 may implement the foregoing functions by hardware orcertainly by hardware executing corresponding software.

The transceiver 2001, the processor 2002, and the memory 2003 areconnected to each other. For example, the transceiver 2001, theprocessor 2002, and the memory 2003 are connected to each other by usinga bus 2004. The bus 2004 may be a peripheral component interconnect(PCI) bus, an extended industry standard architecture (EISA) bus, or thelike. The bus may be classified into an address bus, a data bus, acontrol bus, and the like. For ease of representation, only one thickline is used to represent the bus in FIG. 20, but this does not meanthat there is only one bus or only one type of bus.

The transceiver 2001 is configured to: communicate and interact withanother device.

The processor 2002 is configured to implement the synchronization methodshown in FIG. 24, FIG. 26, or FIG. 28. For details, refer to the relateddescriptions in the embodiment shown in FIG. 24, FIG. 26, or FIG. 28.The details are not described herein again.

The memory 2003 is configured to store a program and the like. Forexample, the program may include program code, and the program codeincludes a computer operation instruction. The memory 2003 may include aRAM, and may further include a non-volatile memory, for example, atleast one magnetic disk storage. The processor 2002 performs theapplication program stored in the memory 2003, to implement theforegoing function, so as to implement the synchronization method shownin FIG. 24, FIG. 26, or FIG. 28.

In conclusion, according to the synchronization method and the apparatusthat are provided in the embodiments of this application, in a clocksynchronization process, impact of a transmission delay between thefirst device and the second device can be avoided, so that a clockprecision requirement of an industrial factory can be met in a scenarioin which the mobile network is connected to the Ethernet network.

One of ordinary skilled in the art should understand that theembodiments of this application may be provided as a method, a system,or a computer program product. Therefore, this application may be in aform of a full hardware embodiment, a full software embodiment, or acombination of software and hardware embodiments. In addition, thisapplication may use a form of a computer program product that isimplemented on one or more computer usable storage media (including butnot limited to a magnetic disk storage, a CD-ROM, an optical memory, andthe like) that include computer usable program code.

This application is described with reference to the flowcharts and/orblock diagrams of the method, the device (system), and the computerprogram product according to the embodiments of this application. Itshould be understood that computer program instructions may be used toimplement each procedure and/or each block in the flowcharts and/or theblock diagrams and a combination of a procedure and/or a block in theflowcharts and/or the block diagrams. These computer programinstructions may be provided for a general-purpose computer, aspecial-purpose computer, an embedded processor, or a processor ofanother programmable data processing device to generate a machine, sothat the instructions executed by a computer or a processor of anotherprogrammable data processing device generate an apparatus forimplementing a function in one or more procedures in the flowchartsand/or in one or more blocks in the block diagrams.

These computer program instructions may be stored in a computer readablememory that can instruct the computer or another programmable dataprocessing device to work in a manner, so that the instructions storedin the computer readable memory generate an artifact that includes aninstruction apparatus. The instruction apparatus implements a functionin one or more procedures in the flowcharts and/or in one or more blocksin the block diagrams.

These computer program instructions may alternatively be loaded onto thecomputer or the another programmable data processing device, so that aseries of operations and operations are performed on the computer or theanother programmable device, thereby generating computer-implementedprocessing. Therefore, the instructions executed on the computer or theanother programmable device provide operations for implementing afunction in one or more procedures in the flowcharts and/or in one ormore blocks in the block diagrams.

Definitely, one of ordinary skilled in the art can make variousmodifications and variations to the embodiments of this applicationwithout departing from the scope of the embodiments of this application.This application is intended to cover these modifications and variationsprovided that they fall within the scope of protection defined by thefollowing claims and their equivalent technologies.

What is claimed is:
 1. A synchronization method, comprising: sending, by a first device, a first packet to an access device, wherein the first packet carries first timestamp information, wherein the first timestamp information is a moment in an Ethernet network at which the first device sends the first packet; determining second timestamp information, wherein the second timestamp information is a moment in a mobile network at which the first device sends the first packet; receiving, by the first device, a second packet from the access device, wherein the second packet carries third timestamp information and fourth timestamp information, wherein the third timestamp information is a moment in the mobile network at which a second device receives a third packet from the access device in response to the first packet, wherein the fourth timestamp information is a moment in the mobile network at which the second device sends a fourth packet to the access device, and wherein the second packet is sent by the access device to the first device in response to the fourth packet; determining, by the first device, fifth timestamp information and sixth timestamp information, wherein the fifth timestamp information is a moment in the Ethernet network at which the first device receives the second packet, and wherein the sixth timestamp information is a moment in the mobile network at which the first device receives the second packet; determining, by the first device, seventh timestamp information based on the second timestamp information, the third timestamp information, the fourth timestamp information, the fifth timestamp information, and the sixth timestamp information; and forwarding, by the first device, the seventh timestamp information to the second device via the access device, wherein a clock of the second device is synchronized with a clock of the first device based on the seventh timestamp information, wherein the first device is a user plane network element and the second device is a terminal device, or the first device is a terminal device and the second device is a user plane network element.
 2. The method according to claim 1, wherein determining the seventh timestamp information comprises: determining, by the first device, a round-trip transmission delay difference between the first device and the second device based on the second timestamp information, the third timestamp information, the fourth timestamp information, and the sixth timestamp information; and calculating, by the first device, a sum of the moment corresponding to the fifth timestamp information and the round-trip transmission delay difference, to obtain the seventh timestamp information.
 3. The method according to claim 1, wherein after receiving the second packet from the access device, the method further comprises: extracting, by the first device, the third timestamp information and the fourth timestamp information that are carried in a first protocol field comprised in the second packet.
 4. The method according to claim 3, wherein the first protocol field is a general packet radio service (GPRS) tunneling protocol (GTP) field when the first device is the user plane network element.
 5. The method according to claim 3, wherein the first protocol field is a service data protocol (SDAP) field or a packet data convergence protocol (PDCP) field when the first device is the terminal device.
 6. A synchronization method, comprising: receiving, by a second device, a third packet from an access device, wherein the third packet carries first timestamp information indicating a moment in an Ethernet network at which a first device sends a first packet, wherein the third packet is sent by the access device in response to the first packet, and wherein the first device is a user plane network element and the second device is a terminal device, or the first device is a terminal device and the second device is a user plane network element; determining, by the second device, third timestamp information and eighth timestamp information, wherein the third timestamp information is a moment in a mobile network at which the second device receives the third packet, and wherein the eighth timestamp information is a moment that is in the Ethernet network at which the second device receives the third packet; sending, by the second device, a fourth packet to the access device, wherein the fourth packet carries the third timestamp information and fourth timestamp information, and wherein the fourth timestamp information is a moment in the mobile network at which the second device sends the fourth packet to the access device; determining, by the second device, ninth timestamp information, wherein the ninth timestamp information is a moment in the Ethernet network at which the second device sends the fourth packet to the access device; receiving, by the second device, seventh timestamp information from the access device, wherein a clock of the second device is synchronized with a clock of the first device based on the seventh timestamp information; and determining, by the second device, a time offset between the first device and the second device based on the first timestamp information, the eighth timestamp information, the ninth timestamp information, and the seventh timestamp information; and performing time synchronization based on the time offset.
 7. The method according to claim 6, further comprising: determining, by the second device based on the seventh timestamp information indicating a moment in the Ethernet network at which the first device receives a second packet, wherein the second packet is sent by the access device to the first device in response to the fourth packet.
 8. The method according to claim 6, wherein the second device uses a second protocol field comprised in the fourth packet to carry the third timestamp information and the fourth timestamp information.
 9. The method according to claim 8, wherein the second protocol field is a service data protocol (SDAP) field or a packet data convergence protocol (PDCP) field when the second device is the terminal device.
 10. The method according to claim 8, wherein the second protocol field is a general packet radio service (GPRS) tunneling protocol (GTP) field when the second device is the user plane network element.
 11. A first device, comprising: a memory to store program instructions; and a processor coupled to the memory, wherein the program instructions cause the processor to: send a first packet to an access device, wherein the first packet carries first timestamp information indicating a moment in an Ethernet network at which the first device sends the first packet; determine second timestamp information indicating a moment in a mobile network and at which the first device sends the first packet; receive a second packet from the access device, wherein the second packet carries third timestamp information and fourth timestamp information, wherein the third timestamp information is a moment in the mobile network at which a second device receives a third packet sent by the access device to the second device in response to the first packet, wherein the fourth timestamp information is a moment in the mobile network at which the second device sends a fourth packet to the access device, and wherein the second packet is sent by the access device to the first device in response to the fourth packet; determine fifth timestamp information and sixth timestamp information, wherein the fifth timestamp information is a moment in the Ethernet network at which the first device receives the second packet, and wherein the sixth timestamp information is a moment in the mobile network at which the first device receives the second packet; determine seventh timestamp information based on the second timestamp information, the third timestamp information, the fourth timestamp information, the fifth timestamp information, and the sixth timestamp information; and forward the seventh timestamp information to the second device by using the access device, wherein a clock of the second device is synchronized with a clock of the first device based on the seventh timestamp information, wherein the first device is a user plane network element and the second device is a terminal device, or the first device is a terminal device and the second device is a user plane network element.
 12. The first device according to claim 11, wherein the processor is further to: determine a round-trip transmission delay difference between the first device and the second device based on the second timestamp information, the third timestamp information, the fourth timestamp information, and the sixth timestamp information; and calculate a sum of the moment corresponding to the fifth timestamp information and the round-trip transmission delay difference, to obtain the seventh timestamp information.
 13. The first device according to claim 11, wherein the processor is further to: after receiving the second packet from the access device, extract the third timestamp information and the fourth timestamp information that are carried in a first protocol field comprised in the second packet.
 14. The first device according to claim 13, wherein the first protocol field is a general packet radio service (GPRS) tunneling protocol (GTP) field when the first device is the user plane network element.
 15. The first device according to claim 13, wherein the first protocol field is a service data protocol (SDAP) field or a packet data convergence protocol (PDCP) field when the first device is the terminal device.
 16. A second device, comprising: a memory to store program instructions; and a processor coupled to the memory, wherein the program instructions cause the processor to: receive a third packet from an access device, wherein the third packet carries first timestamp information, wherein the first timestamp information is a moment in an Ethernet network at which a first device sends a first packet, and wherein the third packet is sent by the access device in response to the first packet, and wherein the first device is a user plane network element and the second device is a terminal device, or the first device is a terminal device and the second device is a user plane network element; determine third timestamp information and eighth timestamp information, wherein the third timestamp information is a moment in a mobile network at which the second device receives the third packet, and wherein the eighth timestamp information is a moment in the Ethernet network at which the second device receives the third packet; and send a fourth packet to the access device, wherein the fourth packet carries the third timestamp information and fourth timestamp information, and wherein the fourth timestamp information is a moment in the mobile network at which the second device sends the fourth packet to the access device; determine ninth timestamp information indicating a moment in the Ethernet network at which the second device sends the fourth packet to the access device; receive seventh timestamp information from the access device, wherein a clock of the second device is synchronized with a clock of the first device based on the seventh timestamp information; and determine a time offset between the first device and the second device based on the first timestamp information, the eighth timestamp information, the ninth timestamp information, and the seventh timestamp information; and perform time synchronization based on the time offset.
 17. The second device according to claim 16, wherein the processor is further to: determine, based on the seventh timestamp information, a moment that is in the Ethernet network at which the first device receives a second packet, wherein the second packet is sent by the access device to the first device in response to the fourth packet.
 18. The second device according to claim 16, wherein the processor is further to: use a second protocol field comprised in the fourth packet to carry the third timestamp information and the fourth timestamp information when the fourth packet carries the third timestamp information and the fourth timestamp information.
 19. The second device according to claim 18, wherein the second protocol field is a service data protocol (SDAP) field or a packet data convergence protocol (PDCP) field when the second device is the terminal device.
 20. The second device according to claim 18, wherein the second protocol field is a general packet radio service (GPRS) tunneling protocol (GTP) field when the second device is the user plane network element. 